private void bindDiscriminatorSubclassEntities( AbstractEntitySourceImpl entitySource, PersistentClass superEntityDescriptor) { for ( IdentifiableTypeSource subType : entitySource.getSubTypes() ) { final SingleTableSubclass subEntityDescriptor = new SingleTableSubclass( superEntityDescriptor, metadataBuildingContext ); bindDiscriminatorSubclassEntity( (SubclassEntitySourceImpl) subType, subEntityDescriptor ); superEntityDescriptor.addSubclass( subEntityDescriptor ); entitySource.getLocalMetadataBuildingContext().getMetadataCollector().addEntityBinding( subEntityDescriptor ); } }
protected Iterator getDiscriminatorColumnIterator() { if ( isDiscriminatorInsertable() && !getDiscriminator().hasFormula() ) { return getDiscriminator().getColumnIterator(); } else { return super.getDiscriminatorColumnIterator(); } }
public void validate(Mapping mapping) throws MappingException { if ( getDiscriminator() == null ) { throw new MappingException( "No discriminator found for " + getEntityName() + ". Discriminator is needed when 'single-table-per-hierarchy' " + "is used and a class has subclasses" ); } super.validate( mapping ); } }
@SuppressWarnings("unchecked") protected Iterator getNonDuplicatedPropertyIterator() { return new JoinedIterator( getSuperclass().getUnjoinedPropertyIterator(), getUnjoinedPropertyIterator() ); }
@Test public void testProperCallbacks() { PersistentClassVisitorValidator vv = new PersistentClassVisitorValidator(); new RootClass( metadataBuildingContext ).accept( vv ); new Subclass( new RootClass( metadataBuildingContext ), metadataBuildingContext ).accept( vv ); new JoinedSubclass( new RootClass( metadataBuildingContext ), metadataBuildingContext ).accept( vv ); new SingleTableSubclass( new RootClass( metadataBuildingContext ), metadataBuildingContext ).accept( vv ); new UnionSubclass( new RootClass( metadataBuildingContext ), metadataBuildingContext ).accept( vv ); }
Locale.ENGLISH, "Unable to locate entity table xref for entity [%s] super-type [%s]", entityDescriptor.getEntityName(), superEntityName ), database.toIdentifier( entitySource.getLocalMetadataBuildingContext().getMetadataCollector().getLogicalTableName( entityDescriptor.getTable() entityDescriptor.getTable(), superEntityTableXref );
protected Iterator getNonDuplicatedPropertyIterator() { return new JoinedIterator( getSuperclass().getUnjoinedPropertyIterator(), getUnjoinedPropertyIterator() ); }
Locale.ENGLISH, "Unable to locate entity table xref for entity [%s] super-type [%s]", entityDescriptor.getEntityName(), superEntityName ), database.toIdentifier( entityDescriptor.getTable().getName() ), entityDescriptor.getTable(), superEntityTableXref );
private static PersistentClass makePersistentClass( InheritanceState inheritanceState, PersistentClass superEntity, MetadataBuildingContext metadataBuildingContext) { //we now know what kind of persistent entity it is if ( !inheritanceState.hasParents() ) { return new RootClass( metadataBuildingContext ); } else if ( InheritanceType.SINGLE_TABLE.equals( inheritanceState.getType() ) ) { return new SingleTableSubclass( superEntity, metadataBuildingContext ); } else if ( InheritanceType.JOINED.equals( inheritanceState.getType() ) ) { return new JoinedSubclass( superEntity, metadataBuildingContext ); } else if ( InheritanceType.TABLE_PER_CLASS.equals( inheritanceState.getType() ) ) { return new UnionSubclass( superEntity, metadataBuildingContext ); } else { throw new AssertionFailure( "Unknown inheritance type: " + inheritanceState.getType() ); } }
protected Iterator getNonDuplicatedPropertyIterator() { return new JoinedIterator( getSuperclass().getUnjoinedPropertyIterator(), getUnjoinedPropertyIterator() ); }
protected Iterator getDiscriminatorColumnIterator() { if ( isDiscriminatorInsertable() && !getDiscriminator().hasFormula() ) { return getDiscriminator().getColumnIterator(); } else { return super.getDiscriminatorColumnIterator(); } }
public void validate(Mapping mapping) throws MappingException { if(getDiscriminator()==null) { throw new MappingException("No discriminator found for " + getEntityName() + ". Discriminator is needed when 'single-table-per-hierarchy' is used and a class has subclasses"); } super.validate(mapping); } }
private static PersistentClass makePersistentClass(InheritanceState inheritanceState, PersistentClass superEntity) { //we now know what kind of persistent entity it is PersistentClass persistentClass; //create persistent class if ( !inheritanceState.hasParents() ) { persistentClass = new RootClass(); } else if ( InheritanceType.SINGLE_TABLE.equals( inheritanceState.getType() ) ) { persistentClass = new SingleTableSubclass( superEntity ); } else if ( InheritanceType.JOINED.equals( inheritanceState.getType() ) ) { persistentClass = new JoinedSubclass( superEntity ); } else if ( InheritanceType.TABLE_PER_CLASS.equals( inheritanceState.getType() ) ) { persistentClass = new UnionSubclass( superEntity ); } else { throw new AssertionFailure( "Unknown inheritance type: " + inheritanceState.getType() ); } return persistentClass; }
protected Iterator getNonDuplicatedPropertyIterator() { return new JoinedIterator( getSuperclass().getUnjoinedPropertyIterator(), getUnjoinedPropertyIterator() ); }
protected Iterator getDiscriminatorColumnIterator() { if ( isDiscriminatorInsertable() && !getDiscriminator().hasFormula() ) { return getDiscriminator().getColumnIterator(); } else { return super.getDiscriminatorColumnIterator(); } }
public void validate(Mapping mapping) throws MappingException { if(getDiscriminator()==null) { throw new MappingException("No discriminator found for " + getEntityName() + ". Discriminator is needed when 'single-table-per-hierarchy' is used and a class has subclasses"); } super.validate(mapping); } }
private static void handleSubclass(PersistentClass model, Mappings mappings, Element subnode, java.util.Map inheritedMetas) throws MappingException { Subclass subclass = new SingleTableSubclass( model ); bindSubclass( subnode, subclass, mappings, inheritedMetas ); model.addSubclass( subclass ); mappings.addClass( subclass ); }
protected Iterator getNonDuplicatedPropertyIterator() { return new JoinedIterator( getSuperclass().getUnjoinedPropertyIterator(), getUnjoinedPropertyIterator() ); }
protected Iterator getDiscriminatorColumnIterator() { if ( isDiscriminatorInsertable() && !getDiscriminator().hasFormula() ) { return getDiscriminator().getColumnIterator(); } else { return super.getDiscriminatorColumnIterator(); } }
public void validate(Mapping mapping) throws MappingException { if(getDiscriminator()==null) { throw new MappingException("No discriminator found for " + getEntityName() + ". Discriminator is needed when 'single-table-per-hierarchy' is used and a class has subclasses"); } super.validate(mapping); } }