当前位置: 首页>>代码示例>>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;未经允许,请勿转载。