@Override public String getLogicalTableName(Table ownerTable) { final Identifier logicalName = physicalToLogicalTableNameMap.get( ownerTable.getNameIdentifier() ); if ( logicalName == null ) { throw new MappingException( "Unable to find physical table: " + ownerTable.getName() ); } return logicalName.render(); }
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(); }
@Override public boolean includeTable(Table table) { // exclude table "the_entity_2" return !"the_entity_2".equals( table.getName() ); }
@Override public boolean includeTable(Table table) { // exclude table "the_entity_2" return !"the_entity_2".equals( table.getName() ); }
public String toString() { if ( !isReferenceToPrimaryKey() ) { return getClass().getName() + '(' + getTable().getName() + getColumns() + " ref-columns:" + '(' + getReferencedColumns() + ") as " + getName() + ")"; } else { return super.toString(); } }
public void createPrimaryKey() { //Primary key constraint PrimaryKey pk = new PrimaryKey( table ); pk.setName( PK_ALIAS.toAliasString( table.getName() ) ); table.setPrimaryKey(pk); pk.addColumns( getKey().getColumnIterator() ); }
@Test public void testTableName() { assert MIDDLE_VERSIONS_ENTITY_NAME.equals( metadata().getEntityBinding( MIDDLE_VERSIONS_ENTITY_NAME ).getTable().getName() ); }
@Test public void testTableName() { assert "naming_test_entity_1_versions".equals( metadata().getEntityBinding( "org.hibernate.envers.test.integration.naming.NamingTestEntity1_AUD" ).getTable().getName() ); } }
protected void checkDefaultCollectionTableName( Class<?> ownerEntityClass, String ownerCollectionPropertyName, String expectedCollectionTableName) { final org.hibernate.mapping.Collection collection = metadata().getCollectionBinding( ownerEntityClass.getName() + '.' + ownerCollectionPropertyName ); final org.hibernate.mapping.Table table = collection.getCollectionTable(); assertEquals( expectedCollectionTableName, table.getName() ); }
@SuppressWarnings({"unchecked"}) @Test public void testTableNames() { assert "sec_embid_versions".equals( ((Iterator<Join>) metadata().getEntityBinding( "org.hibernate.envers.test.integration.secondary.ids.SecondaryEmbIdTestEntity_AUD" ).getJoinIterator()).next().getTable().getName() ); } }
@Test public void testTableName() { assert MIDDLE_VERSIONS_ENTITY_NAME.equals( metadata().getEntityBinding( MIDDLE_VERSIONS_ENTITY_NAME ).getTable().getName() ); }
@Test public void testExpectedTableNameComponent1() { PersistentClass auditClass = metadata().getEntityBinding( COMPONENT_1_AUDIT_JOIN_TABLE_NAME ); assert auditClass != null; assert COMPONENT_1_AUDIT_JOIN_TABLE_NAME.equals( auditClass.getTable() .getName() ); }
@Test public void testExpectedTableNameComponent2() { PersistentClass auditClass = metadata().getEntityBinding( COMPONENT_2_AUDIT_JOIN_TABLE_NAME ); assert auditClass != null; assert COMPONENT_2_AUDIT_JOIN_TABLE_NAME.equals( auditClass.getTable() .getName() ); }
@Test @TestForIssue(jiraKey = "HHH-9327") public void testManyToManyCollectionTable() { final Collection collectionMapping = metadata.getCollectionBinding( Category.class.getName() + "." + "items" ); final String expectedTableName = transformEntityName( Category.class.getName() ) + "_" + transformEntityName( Item.class.getName() ); assertEquals( expectedTableName, collectionMapping.getCollectionTable().getName() ); }
@Test public void testAbstractTableExistence() { for ( Table table : metadata().collectTableMappings() ) { if ( "AbstractEntity_AUD".equals( table.getName() ) ) { Assert.assertFalse( table.isPhysicalTable() ); return; } } Assert.fail(); } }
@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 @TestForIssue(jiraKey = "HHH-5848") public void testDatabaseTableNames() { PersistentClass classMapping = metadata().getEntityBinding( Item.class.getName() ); Column secTabColumn = (Column) classMapping.getProperty( "specialPrice" ).getColumnIterator().next(); assertEquals( "TAB_ITEMS_SEC", secTabColumn.getValue().getTable().getName() ); Column tabColumn = (Column) classMapping.getProperty( "price" ).getColumnIterator().next(); assertEquals( "TAB_ITEMS", tabColumn.getValue().getTable().getName() ); } }
@Test @TestForIssue(jiraKey = "HHH-12975") public void testMapsIdJoinColumnForeignKeyNoConstraint() { for ( Namespace namespace : metadata().getDatabase().getNamespaces() ) { for ( Table table : namespace.getTables() ) { if ( "Post".equals( table.getName() ) ) { assertEquals( 0, table.getForeignKeys().size() ); } } } }
@Test @TestForIssue(jiraKey = "HHH-12975") public void testPrimaryKeyJoinColumnForeignKeyNoConstraint() { for ( Namespace namespace : metadata().getDatabase().getNamespaces() ) { for ( Table table : namespace.getTables() ) { if ( "Car".equals( table.getName() ) ) { assertEquals( 0, table.getForeignKeys().size() ); } } } }
@Test public void testRevEntityTableCreation() { for ( Table table : metadata().collectTableMappings() ) { if ( "REVCHANGES".equals( table.getName() ) ) { assert table.getColumnSpan() == 2; assert table.getColumn( new Column( "REV" ) ) != null; assert table.getColumn( new Column( "ENTITYNAME" ) ) != null; return; } } assert false; }