本文整理汇总了Java中org.hibernate.mapping.Table类的典型用法代码示例。如果您正苦于以下问题:Java Table类的具体用法?Java Table怎么用?Java Table使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Table类属于org.hibernate.mapping包,在下文中一共展示了Table类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configure
import org.hibernate.mapping.Table; //导入依赖的package包/类
@Override
public void configure(Type type, Properties params, Dialect dialect) throws MappingException {
ObjectNameNormalizer normalizer = ( ObjectNameNormalizer ) params.get( IDENTIFIER_NORMALIZER );
sequenceName = normalizer.normalizeIdentifierQuoting(
ConfigurationHelper.getString( SEQUENCE, params, "hibernate_sequence" )
);
parameters = params.getProperty( PARAMETERS );
if ( sequenceName.indexOf( '.' ) < 0 ) {
final String schemaName = normalizer.normalizeIdentifierQuoting( params.getProperty( SCHEMA ) );
final String catalogName = normalizer.normalizeIdentifierQuoting( params.getProperty( CATALOG ) );
sequenceName = Table.qualify(
dialect.quote( catalogName ),
dialect.quote( schemaName ),
dialect.quote( sequenceName )
);
}
else {
// if already qualified there is not much we can do in a portable manner so we pass it
// through and assume the user has set up the name correctly.
}
this.identifierType = type;
sql = dialect.getSequenceNextValString( sequenceName );
}
示例2: addTableName
import org.hibernate.mapping.Table; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void addTableName(MetadataImplementor metadata, ArrayList<String> tables, Table table, String aSchemaName) {
String name = (null == aSchemaName) ? "" : aSchemaName + ".";
name += table.getName();
if (tables.contains(name)) {
return;
}
final Collection<Table> ts = metadata.collectTableMappings();
for (Table t : ts) {
if (t.equals(table)) {
continue;
}
Iterator<ForeignKey> relationships = t.getForeignKeyIterator();
while (relationships.hasNext()) {
ForeignKey fk = relationships.next();
if (fk.getReferencedTable().equals(table)) {
addTableName(metadata, tables, fk.getTable(), aSchemaName);
}
}
}
tables.add(name);
}
示例3: getIndicesExcludingPK
import org.hibernate.mapping.Table; //导入依赖的package包/类
private Set<String> getIndicesExcludingPK(Table table)
{
Set<String> res = new HashSet<>();
try (ResultSet indices = dialect.getMetadata().getIndexInfo(table.getCatalog(), table.getSchema(),
table.getName(), false, false))
{
while (indices.next())
{
if (!indices.getString("INDEX_NAME").equalsIgnoreCase("PRIMARY_KEY"))
res.add(indices.getString("INDEX_NAME"));
}
}
catch (SQLException e)
{
// ignore at this point, just return an empty set
}
return res;
}
示例4: 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;
}
示例5: 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;
}
示例6: 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;
}
示例7: 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;
}
示例8: getAddIndexesIfRequired
import org.hibernate.mapping.Table; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public Collection<? extends String> getAddIndexesIfRequired(Session session, String tableName, String... indexes)
{
final Table table = findTable(tableName);
List<String> sqlStrings = new ArrayList<String>();
Map<Set<String>, String> revIndexMap = getExistingIndexes(table, session);
Set<String> indexSet = new HashSet<String>(Arrays.asList(indexes));
Iterator<Index> indexIterator = table.getIndexIterator();
while( indexIterator.hasNext() )
{
Index index = indexIterator.next();
if( !indexSet.remove(index.getName()) )
{
continue;
}
processIndex(table, index, revIndexMap, sqlStrings);
}
if( !indexSet.isEmpty() )
{
throw new RuntimeException("Failed to find indexes:" + indexSet + " on table: " + tableName);
}
return sqlStrings;
}
示例9: getAddIndexesRawIfRequired
import org.hibernate.mapping.Table; //导入依赖的package包/类
public Collection<? extends String> getAddIndexesRawIfRequired(Session session, String tableName,
String[]... indexes)
{
List<String> sqlStrings = new ArrayList<String>();
final Table table = findTable(tableName);
Map<Set<String>, String> revIndexMap = getExistingIndexes(table, session);
for( String[] index : indexes )
{
Index indexObj = new Index();
indexObj.setTable(table);
indexObj.setName(index[0]);
for( int i = 1; i < index.length; i++ )
{
Column col = new Column(index[i]);
indexObj.addColumn(col);
}
processIndex(table, indexObj, revIndexMap, sqlStrings);
}
return sqlStrings;
}
示例10: getAddIndexesRaw
import org.hibernate.mapping.Table; //导入依赖的package包/类
public Collection<? extends String> getAddIndexesRaw(String tableName, String[]... indexes)
{
List<String> sqlStrings = new ArrayList<String>();
final Table table = findTable(tableName);
for( String[] index : indexes )
{
Index indexObj = new Index();
indexObj.setTable(table);
indexObj.setName(index[0]);
for( int i = 1; i < index.length; i++ )
{
Column col = new Column(index[i]);
indexObj.addColumn(col);
}
sqlStrings.add(indexObj.sqlCreateString(dialect, mapping, defaultCatalog, defaultSchema));
}
return sqlStrings;
}
示例11: processIndex
import org.hibernate.mapping.Table; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void processIndex(Table table, Index index, Map<Set<String>, String> revIndexMap, List<String> sqlStrings)
{
Iterator<Column> colIter = index.getColumnIterator();
Set<String> indexCols = new HashSet<String>();
while( colIter.hasNext() )
{
Column col = colIter.next();
indexCols.add(col.getName().toLowerCase());
}
String existingIndex = revIndexMap.get(indexCols);
if( existingIndex != null )
{
if( existingIndex.equalsIgnoreCase(index.getName()) )
{
return;
}
else
{
sqlStrings.add(extDialect.getDropIndexSql(table.getName(), '`' + existingIndex + '`'));
}
}
sqlStrings.add(index.sqlCreateString(dialect, mapping, defaultCatalog, defaultSchema));
}
示例12: determineSequenceName
import org.hibernate.mapping.Table; //导入依赖的package包/类
/**
* Determine the name of the sequence (or table if this resolves to a physical table)
* to use.
* <p/>
* Called during {@link #configure configuration}.
*
* @param params The params supplied in the generator config (plus some standard useful extras).
* @param dialect The dialect in effect
* @return The sequence name
*/
protected String determineSequenceName(Properties params, Dialect dialect) {
final String sequencePerEntitySuffix = ConfigurationHelper.getString( CONFIG_SEQUENCE_PER_ENTITY_SUFFIX, params, DEF_SEQUENCE_SUFFIX );
// JPA_ENTITY_NAME value honors <class ... entity-name="..."> (HBM) and @Entity#name (JPA) overrides.
String sequenceName = ConfigurationHelper.getBoolean( CONFIG_PREFER_SEQUENCE_PER_ENTITY, params, false )
? params.getProperty( JPA_ENTITY_NAME ) + sequencePerEntitySuffix
: DEF_SEQUENCE_NAME;
final ObjectNameNormalizer normalizer = (ObjectNameNormalizer) params.get( IDENTIFIER_NORMALIZER );
sequenceName = ConfigurationHelper.getString( SEQUENCE_PARAM, params, sequenceName );
if ( sequenceName.indexOf( '.' ) < 0 ) {
sequenceName = normalizer.normalizeIdentifierQuoting( sequenceName );
final String schemaName = params.getProperty( SCHEMA );
final String catalogName = params.getProperty( CATALOG );
sequenceName = Table.qualify(
dialect.quote( catalogName ),
dialect.quote( schemaName ),
dialect.quote( sequenceName )
);
}
// if already qualified there is not much we can do in a portable manner so we pass it
// through and assume the user has set up the name correctly.
return sequenceName;
}
示例13: bindDiscriminatorProperty
import org.hibernate.mapping.Table; //导入依赖的package包/类
private static void bindDiscriminatorProperty(Table table, RootClass entity, Element subnode,
Mappings mappings) {
SimpleValue discrim = new SimpleValue( mappings, table );
entity.setDiscriminator( discrim );
bindSimpleValue(
subnode,
discrim,
false,
RootClass.DEFAULT_DISCRIMINATOR_COLUMN_NAME,
mappings
);
if ( !discrim.isTypeSpecified() ) {
discrim.setTypeName( "string" );
// ( (Column) discrim.getColumnIterator().next() ).setType(type);
}
entity.setPolymorphic( true );
final String explicitForceValue = subnode.attributeValue( "force" );
boolean forceDiscriminatorInSelects = explicitForceValue == null
? mappings.forceDiscriminatorInSelectsByDefault()
: "true".equals( explicitForceValue );
entity.setForceDiscriminator( forceDiscriminatorInSelects );
if ( "false".equals( subnode.attributeValue( "insert" ) ) ) {
entity.setDiscriminatorInsertable( false );
}
}
示例14: getClassTableName
import org.hibernate.mapping.Table; //导入依赖的package包/类
private static String getClassTableName(
PersistentClass model,
Element node,
String schema,
String catalog,
Table denormalizedSuperTable,
Mappings mappings) {
Attribute tableNameNode = node.attribute( "table" );
String logicalTableName;
String physicalTableName;
if ( tableNameNode == null ) {
logicalTableName = StringHelper.unqualify( model.getEntityName() );
physicalTableName = getNamingStrategyDelegate( mappings ).determineImplicitPrimaryTableName(
model.getEntityName(),
model.getJpaEntityName()
);
}
else {
logicalTableName = tableNameNode.getValue();
physicalTableName = getNamingStrategyDelegate( mappings ).toPhysicalTableName( logicalTableName );
}
mappings.addTableBinding( schema, catalog, logicalTableName, physicalTableName, denormalizedSuperTable );
return physicalTableName;
}
示例15: addDenormalizedTable
import org.hibernate.mapping.Table; //导入依赖的package包/类
public Table addDenormalizedTable(
String schema,
String catalog,
String name,
boolean isAbstract,
String subselect,
Table includedTable) throws DuplicateMappingException {
name = getObjectNameNormalizer().normalizeIdentifierQuoting( name );
schema = getObjectNameNormalizer().normalizeIdentifierQuoting( schema );
catalog = getObjectNameNormalizer().normalizeIdentifierQuoting( catalog );
String key = subselect == null ? Table.qualify(catalog, schema, name) : subselect;
if ( tables.containsKey( key ) ) {
throw new DuplicateMappingException( "table", name );
}
Table table = new DenormalizedTable( includedTable );
table.setAbstract( isAbstract );
table.setName( name );
table.setSchema( schema );
table.setCatalog( catalog );
table.setSubselect( subselect );
tables.put( key, table );
return table;
}