當前位置: 首頁>>代碼示例>>Java>>正文


Java Dialect.getAddForeignKeyConstraintString方法代碼示例

本文整理匯總了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;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:26,代碼來源:ForeignKey.java

示例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();
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:39,代碼來源:ForeignKey.java


注:本文中的org.hibernate.dialect.Dialect.getAddForeignKeyConstraintString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。