本文整理汇总了Java中org.hibernate.mapping.Table.getUniqueKeyIterator方法的典型用法代码示例。如果您正苦于以下问题:Java Table.getUniqueKeyIterator方法的具体用法?Java Table.getUniqueKeyIterator怎么用?Java Table.getUniqueKeyIterator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hibernate.mapping.Table
的用法示例。
在下文中一共展示了Table.getUniqueKeyIterator方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: hasUniqueIndex
import org.hibernate.mapping.Table; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private boolean hasUniqueIndex(Index index, Table table)
{
HashSet<Column> indexCols = new HashSet<Column>();
Iterator<Column> icolIter = index.getColumnIterator();
while( icolIter.hasNext() )
{
Column col = icolIter.next();
indexCols.add(col);
if( index.getColumnSpan() == 1 && table.getColumn(col).isUnique() )
{
return true;
}
}
Iterator<UniqueKey> iter = table.getUniqueKeyIterator();
while( iter.hasNext() )
{
UniqueKey uk = iter.next();
if( uk.getColumnSpan() == indexCols.size() && indexCols.containsAll(uk.getColumns()) )
{
return true;
}
}
return false;
}
示例2: getAddIndexesAndConstraintsForColumns
import org.hibernate.mapping.Table; //导入方法依赖的package包/类
@SuppressWarnings({"unchecked"})
public List<String> getAddIndexesAndConstraintsForColumns(String tableName, boolean includeForeignKeyConstraints,
String... columnNames)
{
Set<Column> colSet = new HashSet<Column>();
for( String columnName : columnNames )
{
colSet.add(new Column(columnName));
}
List<String> sqlStrings = new ArrayList<String>();
Table table = findTable(tableName);
if( !extDialect.supportsModifyWithConstraints() )
{
for( Column col : colSet )
{
Column realCol = table.getColumn(col);
if( realCol.isUnique() )
{
table.createUniqueKey(Collections.singletonList(realCol));
}
}
}
Iterator<UniqueKey> keyIter = table.getUniqueKeyIterator();
if( dialect.supportsUniqueConstraintInCreateAlterTable() )
{
while( keyIter.hasNext() )
{
UniqueKey uk = keyIter.next();
if( !Collections.disjoint(uk.getColumns(), colSet) )
{
StringBuilder buf = new StringBuilder("alter table ");
buf.append(table.getQualifiedName(dialect, defaultCatalog, defaultSchema));
buf.append(" add constraint ");
buf.append(extDialect.getRandomIdentifier());
buf.append(' ');
String constraint = uk.sqlConstraintString(dialect);
if( constraint != null )
{
buf.append(constraint);
sqlStrings.add(buf.toString());
}
}
}
}
else
{
while( keyIter.hasNext() )
{
UniqueKey ukey = keyIter.next();
if( !Collections.disjoint(ukey.getColumns(), colSet) )
{
sqlStrings.add(ukey.sqlCreateString(dialect, mapping, defaultCatalog, defaultSchema));
}
}
}
addIndexSQL(sqlStrings, table, colSet);
// Caller may opt to skip foreign key constraints
if( includeForeignKeyConstraints )
{
Iterator<ForeignKey> fkeyIter = table.getForeignKeyIterator();
while( fkeyIter.hasNext() )
{
ForeignKey fkey = fkeyIter.next();
if( !Collections.disjoint(fkey.getColumns(), colSet) )
{
sqlStrings.add(fkey.sqlCreateString(dialect, mapping, defaultCatalog, defaultSchema));
}
}
}
return sqlStrings;
}