public String toString() { StringBuilder buf = new StringBuilder().append( getClass().getName() ) .append( '(' ); if ( getCatalog() != null ) { buf.append( getCatalog() ).append( "." ); } if ( getSchema() != null ) { buf.append( getSchema() ).append( "." ); } buf.append( getName() ).append( ')' ); return buf.toString(); }
protected String getSchema(String schemaFromAnnotation, Table table) { // Get the schema from the annotation ... String schema = schemaFromAnnotation; // ... if empty, try using the default ... if ( StringTools.isEmpty( schema ) ) { schema = globalCfg.getDefaultSchemaName(); // ... if still empty, use the same as the normal table. if ( StringTools.isEmpty( schema ) ) { schema = table.getSchema(); } } return schema; }
annotations, table.getCatalog(), table.getSchema(), table.getName(), Boolean.valueOf( typeParameters.getProperty( DynamicParameterizedType.IS_PRIMARY_KEY ) ),
@Override public String[] getSqlDropStrings(Table table, Metadata metadata) { StringBuilder buf = new StringBuilder( "drop table " ); if ( dialect.supportsIfExistsBeforeTableName() ) { buf.append( "if exists " ); } final QualifiedName tableName = new QualifiedNameParser.NameParts( Identifier.toIdentifier( table.getCatalog(), table.isCatalogQuoted() ), Identifier.toIdentifier( table.getSchema(), table.isSchemaQuoted() ), table.getNameIdentifier() ); final JdbcEnvironment jdbcEnvironment = metadata.getDatabase().getJdbcEnvironment(); buf.append( jdbcEnvironment.getQualifiedObjectNameFormatter().format( tableName, jdbcEnvironment.getDialect() ) ) .append( dialect.getCascadeConstraintsString() ); if ( dialect.supportsIfExistsAfterTableName() ) { buf.append( " if exists" ); } return new String[] { buf.toString() }; } }
@Test public void testRevinfoSchemaName() { Table revisionTable = metadata().getEntityBinding( "org.hibernate.envers.enhanced.SequenceIdRevisionEntity" ) .getTable(); assert SCHEMA_NAME.equals( revisionTable.getSchema() ); }
@Override public void addSecondaryTable(QualifiedTableName logicalQualifiedTableName, Join secondaryTableJoin) { Identifier logicalName = logicalQualifiedTableName.getTableName(); if ( Identifier.areEqual( Identifier.toIdentifier( new QualifiedTableName( Identifier.toIdentifier( primaryTable.getCatalog() ), Identifier.toIdentifier( primaryTable.getSchema() ), primaryTableLogicalName ).render() ), Identifier.toIdentifier( logicalQualifiedTableName.render() ) ) ) { throw new DuplicateSecondaryTableException( logicalName ); } if ( secondaryTableJoinMap == null ) { //secondaryTableJoinMap = new HashMap<Identifier,Join>(); //secondaryTableJoinMap.put( logicalName, secondaryTableJoin ); secondaryTableJoinMap = new HashMap<>(); secondaryTableJoinMap.put( logicalName.getCanonicalName(), secondaryTableJoin ); } else { //final Join existing = secondaryTableJoinMap.put( logicalName, secondaryTableJoin ); final Join existing = secondaryTableJoinMap.put( logicalName.getCanonicalName(), secondaryTableJoin ); if ( existing != null ) { throw new DuplicateSecondaryTableException( logicalName ); } } }
final QualifiedName tableName = new QualifiedNameParser.NameParts( Identifier.toIdentifier( table.getCatalog(), table.isCatalogQuoted() ), Identifier.toIdentifier( table.getSchema(), table.isSchemaQuoted() ), table.getNameIdentifier() );
@Test public void testJoinTableSchemaName() { for ( Table table : metadata().collectTableMappings() ) { if ( TABLE_NAME.equals( table.getName() ) ) { Assert.assertEquals( SCHEMA_NAME, table.getSchema() ); return; } } Assert.fail(); }
@Test public void testNoCircularityDetection() { StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().build(); try { final Metadata metadata = new MetadataSources( ssr ) .addAnnotatedClass( Entity1.class ) .addAnnotatedClass( Entity2.class ) .buildMetadata(); org.hibernate.mapping.Table entity1Table = metadata.getEntityBinding( Entity1.class.getName() ).getTable(); org.hibernate.mapping.Table entity2Table = metadata.getEntityBinding( Entity2.class.getName() ).getTable(); assertTrue( entity1Table.getName().equals( entity2Table.getName() ) ); assertFalse( entity1Table.getSchema().equals( entity2Table.getSchema() ) ); } finally { StandardServiceRegistryBuilder.destroy( ssr ); } }
typeParameters = new Properties(); typeParameters.setProperty( EnumType.ENUM, returnedClassOrElement.getName() ); String schema = columns[0].getTable().getSchema(); schema = schema == null ? "" : schema; String catalog = columns[0].getTable().getCatalog();
public String toString() { StringBuilder buf = new StringBuilder().append( getClass().getName() ) .append( '(' ); if ( getCatalog() != null ) { buf.append( getCatalog() ).append( "." ); } if ( getSchema() != null ) { buf.append( getSchema() ).append( "." ); } buf.append( getName() ).append( ')' ); return buf.toString(); }
public Object accept(Set o) { Assert.assertEquals(o.getCollectionTable().getSchema(), null); return null; } });
private void manageIncrementGenerator(Mappings mappings, Table tab, SimpleValue id, String entityName) { id.setIdentifierGeneratorStrategy("increment"); Properties params = new Properties(); params.put(PersistentIdentifierGenerator.IDENTIFIER_NORMALIZER, mappings.getObjectNameNormalizer()); params.setProperty(PersistentIdentifierGenerator.SCHEMA, quoteIdentifier(tab.getSchema())); params.put(IncrementGenerator.ENTITY_NAME, entityName); id.setIdentifierGeneratorProperties(params); id.setNullValue(null); }
private void setSchemaSelection(Table table) { tableSelector.clearSchemaSelections(); tableSelector.addSchemaSelection( new SchemaSelection( table .getCatalog(), table.getSchema(), table.getName() ) ); }
public static TableIdentifier createTableIdentifier( Table table, String defaultCatalog, String defaultSchema) { String tableName = table.getName(); String tableCatalog = getCatalogForModel(table.getCatalog(), defaultCatalog); String tableSchema = getSchemaForModel(table.getSchema(), defaultSchema); return new TableIdentifier(tableCatalog, tableSchema, tableName); }
public static TableIdentifier createTableIdentifier( Table table, String defaultCatalog, String defaultSchema) { String tableName = table.getName(); String tableCatalog = getCatalogForModel(table.getCatalog(), defaultCatalog); String tableSchema = getSchemaForModel(table.getSchema(), defaultSchema); return new TableIdentifier(tableCatalog, tableSchema, tableName); }
private void setSchemaSelection(Table table) { tableSelector.clearSchemaSelections(); tableSelector.addSchemaSelection( new SchemaSelection( table .getCatalog(), table.getSchema(), table.getName() ) ); }
public Table getTable(String schema, String catalog, String name) { for (Table table : metadataCollector.collectTableMappings()) { if (equalOrBothNull(schema, table.getSchema()) && equalOrBothNull(catalog, table.getCatalog()) && equalOrBothNull(name, table.getName())) { return table; } } return null; }
private TableMetadata getTableMetadata(Connection connection, Table table) throws SQLException { String tableSchema = table.getSchema(); if (tableSchema == null) tableSchema = getDefaultSchema(); String tableCatalog = table.getCatalog(); if (tableCatalog == null) tableCatalog = getDefaultCatalog(); return getDatabaseMetadata(connection) .getTableMetadata(table.getName(), tableSchema, tableCatalog, table.isQuoted()); }