/** * @deprecated Use {@link OneToOne#OneToOne(MetadataBuildingContext, Table, PersistentClass)} instead. */ @Deprecated public OneToOne(MetadataImplementor metadata, Table table, PersistentClass owner) throws MappingException { super( metadata, table ); this.identifier = owner.getKey(); this.entityName = owner.getEntityName(); }
public OneToOne(MetadataBuildingContext buildingContext, Table table, PersistentClass owner) throws MappingException { super( buildingContext, table ); this.identifier = owner.getKey(); this.entityName = owner.getEntityName(); }
public int getColumnSpan() { return associatedClass.getKey().getColumnSpan(); }
public Iterator<Selectable> getColumnIterator() { return associatedClass.getKey().getColumnIterator(); }
public void doSecondPass(Map persistentClasses) throws MappingException { PersistentClass referencedEntity = (PersistentClass) persistentClasses.get( referencedEntityName ); if ( referencedEntity == null ) { throw new AnnotationException( "Unknown entity name: " + referencedEntityName ); } TableBinder.linkJoinColumnWithValueOverridingNameIfImplicit( referencedEntity, referencedEntity.getKey().getColumnIterator(), columns, value); } }
protected void checkColumnDuplication() { HashSet cols = new HashSet(); if ( getIdentifierMapper() == null ) { //an identifier mapper => getKey will be included in the getNonDuplicatedPropertyIterator() //and checked later, so it needs to be excluded checkColumnDuplication( cols, getKey().getColumnIterator() ); } checkColumnDuplication( cols, getDiscriminatorColumnIterator() ); checkPropertyColumnDuplication( cols, getNonDuplicatedPropertyIterator() ); Iterator iter = getJoinIterator(); while ( iter.hasNext() ) { cols.clear(); Join join = (Join) iter.next(); checkColumnDuplication( cols, join.getKey().getColumnIterator() ); checkPropertyColumnDuplication( cols, join.getPropertyIterator() ); } }
@Test public void testChildRevColumnType() { // We need the second column Iterator childEntityKeyColumnsIterator = metadata() .getEntityBinding("org.hibernate.envers.test.integration.inheritance.joined.ChildEntity_AUD" ) .getKey() .getColumnIterator(); childEntityKeyColumnsIterator.next(); Column second = (Column) childEntityKeyColumnsIterator.next(); assertEquals( second.getSqlType(), "int" ); } }
public void createPrimaryKey() { //Primary key constraint final Table table = getTable(); PrimaryKey pk = new PrimaryKey( table ); pk.setName( PK_ALIAS.toAliasString( table.getName() ) ); table.setPrimaryKey( pk ); pk.addColumns( getKey().getColumnIterator() ); }
@Test public void testChildIdColumnName() { Assert.assertEquals( "other_id", ((Column) metadata().getEntityBinding( "org.hibernate.envers.test.integration.inheritance.joined.primarykeyjoin.ChildPrimaryKeyJoinEntity_AUD" ).getKey().getColumnIterator().next()).getName() ); } }
Iterator idColumnsIt = referencedEntity.getKey().getColumnIterator(); while ( idColumnsIt.hasNext() ) { idColumns.add( (Column) idColumnsIt.next() );
protected void checkDefaultJoinColumnName( Class<?> ownerEntityClass, String ownerCollectionPropertyName, String ownerForeignKeyNameExpected) { final org.hibernate.mapping.Collection ownerCollection = metadata().getCollectionBinding( ownerEntityClass.getName() + '.' + ownerCollectionPropertyName ); // The default owner join column can only be computed if it has a PK with 1 column. assertEquals ( 1, ownerCollection.getOwner().getKey().getColumnSpan() ); assertEquals( ownerForeignKeyNameExpected, ownerCollection.getKey().getColumnIterator().next().getText() ); boolean hasOwnerFK = false; for ( Iterator it=ownerCollection.getCollectionTable().getForeignKeyIterator(); it.hasNext(); ) { final ForeignKey fk = (ForeignKey) it.next(); assertSame( ownerCollection.getCollectionTable(), fk.getTable() ); if ( fk.getColumnSpan() > 1 ) { continue; } if ( fk.getColumn( 0 ).getText().equals( ownerForeignKeyNameExpected ) ) { assertSame( ownerCollection.getOwner().getTable(), fk.getReferencedTable() ); hasOwnerFK = true; } } assertTrue( hasOwnerFK ); }
protected void checkDefaultJoinTableAndAllColumnNames( Metadata metadata, Class<?> ownerEntityClass, String ownerCollectionPropertyName, String expectedCollectionTableName, String ownerForeignKeyNameExpected, String[] columnNames) { final org.hibernate.mapping.Collection collection = metadata.getCollectionBinding( ownerEntityClass.getName() + '.' + ownerCollectionPropertyName ); final org.hibernate.mapping.Table table = collection.getCollectionTable(); assertEquals( expectedCollectionTableName, table.getName() ); // The default owner and inverse join columns can only be computed if they have PK with 1 column. assertEquals( 1, collection.getOwner().getKey().getColumnSpan() ); assertEquals( ownerForeignKeyNameExpected, collection.getKey().getColumnIterator().next().getText() ); int columnNumber = table.getColumnSpan(); for ( int i = 0; i < columnNumber; i++ ) { assertEquals( columnNames[i], table.getColumn( i + 1 ).getName()); } }
); assertEquals ( 1, ownerCollection.getOwner().getKey().getColumnSpan() ); assertEquals( ownerForeignKeyNameExpected, ownerCollection.getKey().getColumnIterator().next().getText() ); final PersistentClass associatedPersistentClass = metadata().getEntityBinding( associatedEntityType.getAssociatedEntityName() ); assertEquals( 1, associatedPersistentClass.getKey().getColumnSpan() ); if ( inverseCollectionPropertyName != null ) { final org.hibernate.mapping.Collection inverseCollection = metadata().getCollectionBinding(
public void doSecondPass(Map persistentClasses) throws MappingException { PersistentClass referencedEntity = (PersistentClass) persistentClasses.get( referencedEntityName ); if ( referencedEntity == null ) { throw new AnnotationException( "Unknown entity name: " + referencedEntityName ); }; TableBinder.linkJoinColumnWithValueOverridingNameIfImplicit( referencedEntity, referencedEntity.getKey().getColumnIterator(), columns, value); } }
Iterator idColumnsIt = referencedEntity.getKey().getColumnIterator(); while ( idColumnsIt.hasNext() ) { idColumns.add( (Column) idColumnsIt.next() );
public OneToOne(Mappings mappings, Table table, PersistentClass owner) throws MappingException { super( mappings, table ); this.identifier = owner.getKey(); this.entityName = owner.getEntityName(); }
public void createPrimaryKey() { //Primary key constraint PrimaryKey pk = new PrimaryKey(); Table table = getTable(); pk.setTable(table); pk.setName( PK_ALIAS.toAliasString( table.getName() ) ); table.setPrimaryKey(pk); pk.addColumns( getKey().getColumnIterator() ); }
public void createPrimaryKey() { //Primary key constraint PrimaryKey pk = new PrimaryKey(); Table table = getTable(); pk.setTable(table); pk.setName( PK_ALIAS.toAliasString( table.getName() ) ); table.setPrimaryKey(pk); pk.addColumns( getKey().getColumnIterator() ); }