boolean hasTable() { return !hasParents() || !InheritanceType.SINGLE_TABLE.equals( getType() ); }
boolean hasDenormalizedTable() { return hasParents() && InheritanceType.TABLE_PER_CLASS.equals( getType() ); }
public XClass getClassWithIdClass(boolean evenIfSubclass) { if ( !evenIfSubclass && hasParents() ) { return null; } if ( clazz.isAnnotationPresent( IdClass.class ) ) { return clazz; } else { InheritanceState state = InheritanceState.getSuperclassInheritanceState( clazz, inheritanceStatePerClass ); if ( state != null ) { return state.getClassWithIdClass( true ); } else { return null; } } }
public ElementsToProcess getElementsToProcess() { if ( elementsToProcess == null ) { InheritanceState inheritanceState = inheritanceStatePerClass.get( clazz ); assert !inheritanceState.isEmbeddableSuperclass(); getMappedSuperclassesTillNextEntityOrdered(); accessType = determineDefaultAccessType(); ArrayList<PropertyData> elements = new ArrayList<PropertyData>(); int idPropertyCount = 0; for ( XClass classToProcessForMappedSuperclass : classesToProcessForMappedSuperclass ) { PropertyContainer propertyContainer = new PropertyContainer( classToProcessForMappedSuperclass, clazz, accessType ); int currentIdPropertyCount = AnnotationBinder.addElementsOfClass( elements, propertyContainer, buildingContext ); idPropertyCount += currentIdPropertyCount; } if ( idPropertyCount == 0 && !inheritanceState.hasParents() ) { throw new AnnotationException( "No identifier specified for entity: " + clazz.getName() ); } elements.trimToSize(); elementsToProcess = new ElementsToProcess( elements, idPropertyCount ); } return elementsToProcess; }
private static PersistentClass getSuperEntity( XClass clazzToProcess, Map<XClass, InheritanceState> inheritanceStatePerClass, MetadataBuildingContext context, InheritanceState inheritanceState) { InheritanceState superEntityState = InheritanceState.getInheritanceStateOfSuperEntity( clazzToProcess, inheritanceStatePerClass ); PersistentClass superEntity = superEntityState != null ? context.getMetadataCollector().getEntityBinding( superEntityState.getClazz().getName() ) : null; if ( superEntity == null ) { //check if superclass is not a potential persistent class if ( inheritanceState.hasParents() ) { throw new AssertionFailure( "Subclass has to be binded after it's mother class: " + superEntityState.getClazz().getName() ); } } return superEntity; }
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() ); } }
InheritanceState inheritanceState, EntityBinder entityBinder) { final boolean isRoot = !inheritanceState.hasParents();
PersistentClass superEntity) { Ejb3JoinColumn[] inheritanceJoinedColumns = null; final boolean hasJoinedColumns = inheritanceState.hasParents() && InheritanceType.JOINED.equals( inheritanceState.getType() ); if ( hasJoinedColumns ) {
if ( !inheritanceState.hasParents() ) {
boolean hasTable() { return !hasParents() || !InheritanceType.SINGLE_TABLE.equals( getType() ); }
boolean hasDenormalizedTable() { return hasParents() && InheritanceType.TABLE_PER_CLASS.equals( getType() ); }
public XClass getClassWithIdClass(boolean evenIfSubclass) { if ( !evenIfSubclass && hasParents() ) { return null; } if ( clazz.isAnnotationPresent( IdClass.class ) ) { return clazz; } else { InheritanceState state = InheritanceState.getSuperclassInheritanceState( clazz, inheritanceStatePerClass ); if (state != null){ return state.getClassWithIdClass(true); } else { return null; } } }
public ElementsToProcess getElementsToProcess() { if (elementsToProcess == null) { InheritanceState inheritanceState = inheritanceStatePerClass.get( clazz ); assert !inheritanceState.isEmbeddableSuperclass(); getMappedSuperclassesTillNextEntityOrdered(); accessType = determineDefaultAccessType( ); List<PropertyData> elements = new ArrayList<PropertyData>(); int deep = classesToProcessForMappedSuperclass.size(); int idPropertyCount = 0; for ( int index = 0; index < deep; index++ ) { PropertyContainer propertyContainer = new PropertyContainer( classesToProcessForMappedSuperclass.get( index ), clazz ); int currentIdPropertyCount = AnnotationBinder.addElementsOfClass( elements, accessType, propertyContainer, mappings ); idPropertyCount += currentIdPropertyCount; } if ( idPropertyCount == 0 && !inheritanceState.hasParents() ) { throw new AnnotationException( "No identifier specified for entity: " + clazz.getName() ); } elementsToProcess = new ElementsToProcess( elements, idPropertyCount); } return elementsToProcess; }
final boolean isInheritanceRoot = !inheritanceState.hasParents(); final boolean hasSubclasses = inheritanceState.hasSiblings(); if ( inheritanceState.hasParents() ) { onDeleteAppropriate = true; final JoinedSubclass jsc = ( JoinedSubclass ) persistentClass; && inheritanceState.hasParents(); Set<String> idPropertiesIfIdClass = new HashSet<>(); boolean isIdClass = mapAsIdClass( ); if ( !inheritanceState.hasParents() ) { final RootClass rootClass = ( RootClass ) persistentClass; context.getMetadataCollector().addSecondPass( new CreateKeySecondPass( rootClass ) );
private static PersistentClass getSuperEntity(XClass clazzToProcess, Map<XClass, InheritanceState> inheritanceStatePerClass, ExtendedMappings mappings, InheritanceState inheritanceState) { InheritanceState superEntityState = InheritanceState.getInheritanceStateOfSuperEntity( clazzToProcess, inheritanceStatePerClass ); PersistentClass superEntity = superEntityState != null ? mappings.getClass( superEntityState.getClazz().getName() ) : null; if ( superEntity == null ) { //check if superclass is not a potential persistent class if ( inheritanceState.hasParents() ) { throw new AssertionFailure( "Subclass has to be binded after it's mother class: " + superEntityState.getClazz().getName() ); } } return superEntity; }
private static Ejb3JoinColumn[] makeInheritanceJoinColumns(XClass clazzToProcess, ExtendedMappings mappings, InheritanceState inheritanceState, PersistentClass superEntity) { Ejb3JoinColumn[] inheritanceJoinedColumns = null; final boolean hasJoinedColumns = inheritanceState.hasParents() && InheritanceType.JOINED.equals( inheritanceState.getType() ); if ( hasJoinedColumns ) {
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; }
org.hibernate.annotations.DiscriminatorFormula.class ); if ( !inheritanceState.hasParents() ) { discriminatorColumn = Ejb3DiscriminatorColumn.buildDiscriminatorColumn( discriminatorType, discAnn, discFormulaAnn, mappings ); if ( discAnn != null && inheritanceState.hasParents() ) { log.warn( "Discriminator column has to be defined in the root entity, it will be ignored in subclass: {}", if ( !inheritanceState.hasParents() ) { bindFilters( clazzToProcess, entityBinder, mappings ); if ( InheritanceType.JOINED.equals( inheritanceState.getType() ) && inheritanceState.hasParents() ) { onDeleteAppropriate = true; final JoinedSubclass jsc = ( JoinedSubclass ) persistentClass; if ( inheritanceState.hasParents() ) { if ( persistentClass.getEntityPersisterClass() == null ) { persistentClass.getRootClass().setEntityPersisterClass( SingleTableEntityPersister.class ); if ( inheritanceState.hasParents() ) { if ( persistentClass.getEntityPersisterClass() == null ) { persistentClass.getRootClass().setEntityPersisterClass( UnionSubclassEntityPersister.class ); && inheritanceState.hasParents(); Set<String> idPropertiesIfIdClass = new HashSet<String>(); boolean isIdClass = mapAsIdClass(
if ( !inheritanceState.hasParents() ) { for ( Map.Entry<String, String> filter : filters.entrySet() ) { String filterName = filter.getKey();
boolean hasTable() { return !hasParents() || !InheritanceType.SINGLE_TABLE.equals( getType() ); }