Created
January 2, 2014 19:53
-
-
Save gbadner/8225496 to your computer and use it in GitHub Desktop.
HHH-7472 Index merge
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Index extends AbstractConstraint implements Constraint { | |
protected Index(Table table, String name) { | |
super( table, name ); | |
} | |
@Override | |
public String getExportIdentifier() { | |
StringBuilder sb = new StringBuilder( getTable().getLoggableValueQualifier()); | |
sb.append( ".IDX" ); | |
for ( Column column : getColumns() ) { | |
sb.append( '_' ).append( column.getColumnName().getText() ); | |
} | |
return sb.toString(); | |
} | |
<<<<<<< HEAD | |
public String[] sqlCreateStrings(Dialect dialect) { | |
return new String[] { | |
buildSqlCreateIndexString( | |
dialect, getOrGenerateName(), getTable(), getColumns(), false | |
) | |
}; | |
} | |
public static String buildSqlCreateIndexString( | |
Dialect dialect, | |
String name, | |
TableSpecification table, | |
Iterable<Column> columns, | |
boolean unique | |
) { | |
StringBuilder buf = new StringBuilder( "create" ) | |
.append( unique ? | |
" unique" : | |
"" ) | |
.append( " index " ) | |
.append( dialect.qualifyIndexName() ? | |
name : | |
StringHelper.unqualify( name ) ) | |
.append( " on " ) | |
.append( table.getQualifiedName( dialect ) ) | |
.append( " (" ); | |
boolean first = true; | |
for ( Column column : columns ) { | |
if ( first ) { | |
first = false; | |
} | |
else { | |
buf.append( ", " ); | |
} | |
buf.append( ( column.getColumnName().getText( dialect ) ) ); | |
} | |
buf.append( ")" ); | |
return buf.toString(); | |
} | |
======= | |
>>>>>>> HHH-7472 - Introduce a "schema management" service : externalized exporters | |
@Override | |
protected String getGeneratedNamePrefix() { | |
return "IDX"; | |
} | |
public String sqlConstraintStringInAlterTable(Dialect dialect) { | |
StringBuilder buf = new StringBuilder( " index (" ); | |
boolean first = true; | |
for ( Column column : getColumns() ) { | |
if ( first ) { | |
first = false; | |
} | |
else { | |
buf.append( ", " ); | |
} | |
buf.append( column.getColumnName().getText( dialect ) ); | |
} | |
return buf.append( ')' ).toString(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment