本文整理匯總了Java中org.hibernate.dialect.Dialect.getAddForeignKeyConstraintString方法的典型用法代碼示例。如果您正苦於以下問題:Java Dialect.getAddForeignKeyConstraintString方法的具體用法?Java Dialect.getAddForeignKeyConstraintString怎麽用?Java Dialect.getAddForeignKeyConstraintString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.hibernate.dialect.Dialect
的用法示例。
在下文中一共展示了Dialect.getAddForeignKeyConstraintString方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: sqlConstraintString
import org.hibernate.dialect.Dialect; //導入方法依賴的package包/類
public String sqlConstraintString(Dialect dialect, String constraintName, String defaultCatalog, String defaultSchema) {
String[] cols = new String[ getColumnSpan() ];
String[] refcols = new String[ getColumnSpan() ];
int i=0;
Iterator refiter = null;
if(isReferenceToPrimaryKey() ) {
refiter = referencedTable.getPrimaryKey().getColumnIterator();
}
else {
refiter = referencedColumns.iterator();
}
Iterator iter = getColumnIterator();
while ( iter.hasNext() ) {
cols[i] = ( (Column) iter.next() ).getQuotedName(dialect);
refcols[i] = ( (Column) refiter.next() ).getQuotedName(dialect);
i++;
}
String result = dialect.getAddForeignKeyConstraintString(
constraintName, cols, referencedTable.getQualifiedName(dialect, defaultCatalog, defaultSchema), refcols, isReferenceToPrimaryKey()
);
return cascadeDeleteEnabled && dialect.supportsCascadeDelete() ?
result + " on delete cascade" :
result;
}
示例2: sqlConstraintStringInAlterTable
import org.hibernate.dialect.Dialect; //導入方法依賴的package包/類
public String sqlConstraintStringInAlterTable(Dialect dialect) {
String[] columnNames = new String[ getColumnSpan() ];
String[] targetColumnNames = new String[ getColumnSpan() ];
int i=0;
Iterator<Column> itTargetColumn = getTargetColumns().iterator();
for ( Column column : getColumns() ) {
if ( ! itTargetColumn.hasNext() ) {
throw new MappingException( "More constraint columns that foreign key target columns." );
}
columnNames[i] = column.getColumnName().encloseInQuotesIfQuoted( dialect );
targetColumnNames[i] = ( itTargetColumn.next() ).getColumnName().encloseInQuotesIfQuoted( dialect );
i++;
}
if ( itTargetColumn.hasNext() ) {
throw new MappingException( "More foreign key target columns than constraint columns." );
}
StringBuilder sb =
new StringBuilder(
dialect.getAddForeignKeyConstraintString(
getName(),
columnNames,
targetTable.getQualifiedName( dialect ),
targetColumnNames,
this.targetColumns == null
)
);
// TODO: If a dialect does not support cascade-delete, can it support other actions? (HHH-6428)
// For now, assume not.
if ( dialect.supportsCascadeDelete() ) {
if ( deleteRule != ReferentialAction.NO_ACTION ) {
sb.append( ON_DELETE ).append( deleteRule.getActionString() );
}
if ( updateRule != ReferentialAction.NO_ACTION ) {
sb.append( ON_UPDATE ).append( updateRule.getActionString() );
}
}
return sb.toString();
}