本文整理汇总了Java中org.hibernate.mapping.Table.getColumn方法的典型用法代码示例。如果您正苦于以下问题:Java Table.getColumn方法的具体用法?Java Table.getColumn怎么用?Java Table.getColumn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hibernate.mapping.Table
的用法示例。
在下文中一共展示了Table.getColumn方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getModifyColumnSQL
import org.hibernate.mapping.Table; //导入方法依赖的package包/类
/**
* @param tableName
* @param columnName
* @param changeNotNull
* @param nullable Pass in null to use the annotation on the column. This is
* not always possible (see Redmine #3329).
* @param changeType
* @return
*/
public List<String> getModifyColumnSQL(String tableName, String columnName, boolean changeNotNull,
boolean changeType)
{
List<String> sqlStrings = new ArrayList<String>();
Table table = findTable(tableName);
Column column = table.getColumn(new Column(columnName));
StringBuffer alter = new StringBuffer("alter table ")
.append(table.getQualifiedName(dialect, defaultCatalog, defaultSchema)).append(' ')
.append(extDialect.getModifyColumnSql(mapping, column, changeNotNull, changeType));
sqlStrings.add(alter.toString());
return sqlStrings;
}
示例2: getDropColumnSQL
import org.hibernate.mapping.Table; //导入方法依赖的package包/类
public List<String> getDropColumnSQL(String tableName, String... columns)
{
List<String> sqlStrings = new ArrayList<String>();
Table table = findTable(tableName);
for( String columnName : columns )
{
Column column = table.getColumn(new Column(columnName));
if( column == null )
{
throw new RuntimeException("Could not find column " + columnName + " on table " + tableName);
}
sqlStrings.add(extDialect.getDropColumnSql(table.getQualifiedName(dialect, defaultCatalog, defaultSchema),
column));
}
return sqlStrings;
}
示例3: getAddNotNullSQL
import org.hibernate.mapping.Table; //导入方法依赖的package包/类
public List<String> getAddNotNullSQL(String tableName, String... columns)
{
List<String> sqlStrings = new ArrayList<String>();
Table table = findTable(tableName);
for( String columnName : columns )
{
Column column = table.getColumn(new Column(columnName));
StringBuffer alter = new StringBuffer("alter table ")
.append(table.getQualifiedName(dialect, defaultCatalog, defaultSchema)).append(' ')
.append(extDialect.getAddNotNullSql(mapping, column));
sqlStrings.add(alter.toString());
}
return sqlStrings;
}
示例4: getAddColumnsSQL
import org.hibernate.mapping.Table; //导入方法依赖的package包/类
public List<String> getAddColumnsSQL(String tableName, String... columnNames)
{
List<String> sqlStrings = new ArrayList<String>();
Table table = findTable(tableName);
for( String columnName : columnNames )
{
Column column = table.getColumn(new Column(columnName));
StringBuffer alter = new StringBuffer("alter table ")
.append(table.getQualifiedName(dialect, defaultCatalog, defaultSchema)).append(' ')
.append(dialect.getAddColumnString());
alter.append(' ').append(column.getQuotedName(dialect)).append(' ')
.append(column.getSqlType(dialect, mapping));
boolean useUniqueConstraint = extDialect.supportsModifyWithConstraints() && column.isUnique()
&& dialect.supportsUnique() && (!column.isNullable() || dialect.supportsNotNullUnique());
if( useUniqueConstraint )
{
alter.append(" unique");
}
if( column.hasCheckConstraint() && dialect.supportsColumnCheck() )
{
alter.append(" check(").append(column.getCheckConstraint()).append(")");
}
String columnComment = column.getComment();
if( columnComment != null )
{
alter.append(dialect.getColumnComment(columnComment));
}
sqlStrings.add(alter.toString());
}
return sqlStrings;
}
示例5: getRenameColumnSQL
import org.hibernate.mapping.Table; //导入方法依赖的package包/类
public List<String> getRenameColumnSQL(String tableName, String columnName, String newColumnName)
{
List<String> sqlStrings = new ArrayList<String>();
Table table = findTable(tableName);
Column column = table.getColumn(new Column(columnName));
String alter = null;
alter = extDialect.getRenameColumnSql(table.getQualifiedName(dialect, defaultCatalog, defaultSchema), column,
newColumnName);
sqlStrings.add(alter);
return sqlStrings;
}
示例6: 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;
}