/** * Check to see if a property with the given name exists in the super hierarchy * of this PersistentClass. Does not check this PersistentClass, just up the * hierarchy * * @param name The property name to check * * @return {@code true} if a property with that name exists; {@code false} if not */ public boolean isPropertyDefinedInSuperHierarchy(String name) { return getSuperclass() != null && getSuperclass().isPropertyDefinedInHierarchy( name ); }
/** * @param pc The class for which to get the inheritance type. * * @return The inheritance type of this class. NONE, if this class does not inherit from * another persistent class. */ public static InheritanceType get(PersistentClass pc) { final PersistentClass superclass = pc.getSuperclass(); if ( superclass == null ) { return InheritanceType.NONE; } // We assume that every subclass is of the same type. final Subclass subclass = (Subclass) superclass.getSubclassIterator().next(); if ( subclass instanceof SingleTableSubclass ) { return InheritanceType.SINGLE; } else if ( subclass instanceof JoinedSubclass ) { return InheritanceType.JOINED; } else if ( subclass instanceof UnionSubclass ) { return InheritanceType.TABLE_PER_CLASS; } throw new MappingException( "Unknown subclass class: " + subclass.getClass() ); } }
public void addSubclass(Subclass subclass) throws MappingException { // inheritance cycle detection (paranoid check) PersistentClass superclass = getSuperclass(); while ( superclass != null ) { if ( subclass.getEntityName().equals( superclass.getEntityName() ) ) { throw new MappingException( "Circular inheritance mapping detected: " + subclass.getEntityName() + " will have it self as superclass when extending " + getEntityName() ); } superclass = superclass.getSuperclass(); } subclasses.add( subclass ); }
private PersistentClass getCommonPersistentClass(PersistentClass clazz1, PersistentClass clazz2) { while ( clazz2 != null && clazz2.getMappedClass() != null && clazz1.getMappedClass() != null && !clazz2.getMappedClass() .isAssignableFrom( clazz1.getMappedClass() ) ) { clazz2 = clazz2.getSuperclass(); } return clazz2; }
private String getMappedBy(PersistentClass referencedClass, ValueHolder valueHolder) { // If there's an @AuditMappedBy specified, returning it directly. final String auditMappedBy = propertyAuditingData.getAuditMappedBy(); if ( auditMappedBy != null ) { return auditMappedBy; } // searching in referenced class String mappedBy = this.searchMappedBy( referencedClass, valueHolder ); if ( mappedBy == null ) { LOG.debugf( "Going to search the mapped by attribute for %s in superclasses of entity: %s", propertyName, referencedClass.getClassName() ); PersistentClass tempClass = referencedClass; while ( mappedBy == null && tempClass.getSuperclass() != null ) { LOG.debugf( "Searching in superclass: %s", tempClass.getSuperclass().getClassName() ); mappedBy = this.searchMappedBy( tempClass.getSuperclass(), valueHolder ); tempClass = tempClass.getSuperclass(); } } if ( mappedBy == null ) { throw new MappingException( "Unable to read the mapped by attribute for " + propertyName + " in " + referencedClass.getClassName() + "!" ); } return mappedBy; }
/** * Check to see if a property with the given name exists in this PersistentClass * or in any of its super hierarchy. Unlike {@link #isPropertyDefinedInSuperHierarchy}, * this method does check this PersistentClass * * @param name The property name to check * * @return {@code true} if a property with that name exists; {@code false} if not */ @SuppressWarnings({"WeakerAccess", "RedundantIfStatement"}) public boolean isPropertyDefinedInHierarchy(String name) { if ( hasProperty( name ) ) { return true; } if ( getSuperMappedSuperclass() != null && getSuperMappedSuperclass().isPropertyDefinedInHierarchy( name ) ) { return true; } if ( getSuperclass() != null && getSuperclass().isPropertyDefinedInHierarchy( name ) ) { return true; } return false; }
current = current.getSuperclass();
private Triple<Element, ExtendedPropertyMapper, String> generateInheritanceMappingData( PersistentClass pc, EntityXmlMappingData xmlMappingData, AuditTableData auditTableData, String inheritanceMappingType) { final String extendsEntityName = verEntCfg.getAuditEntityName( pc.getSuperclass().getEntityName() ); final Element classMapping = MetadataTools.createSubclassEntity( xmlMappingData.getMainXmlMapping(), inheritanceMappingType, auditTableData, extendsEntityName, pc.getDiscriminatorValue(), pc.isAbstract() ); // The id and revision type is already mapped in the parent // Getting the property mapper of the parent - when mapping properties, they need to be included final String parentEntityName = pc.getSuperclass().getEntityName(); final EntityConfiguration parentConfiguration = entitiesConfigurations.get( parentEntityName ); if ( parentConfiguration == null ) { throw new MappingException( "Entity '" + pc.getEntityName() + "' is audited, but its superclass: '" + parentEntityName + "' is not." ); } final ExtendedPropertyMapper parentPropertyMapper = parentConfiguration.getPropertyMapper(); final ExtendedPropertyMapper propertyMapper = new SubclassPropertyMapper( new MultiPropertyMapper(), parentPropertyMapper ); return Triple.make( classMapping, propertyMapper, parentEntityName ); }
@SuppressWarnings("unchecked") private static EntityTypeImpl<?> buildEntityType(PersistentClass persistentClass, MetadataContext context) { final Class javaType = persistentClass.getMappedClass(); context.pushEntityWorkedOn( persistentClass ); final MappedSuperclass superMappedSuperclass = persistentClass.getSuperMappedSuperclass(); IdentifiableTypeDescriptor<?> superType = superMappedSuperclass == null ? null : locateOrBuildMappedSuperclassType( superMappedSuperclass, context ); //no mappedSuperclass, check for a super entity if ( superType == null ) { final PersistentClass superPersistentClass = persistentClass.getSuperclass(); superType = superPersistentClass == null ? null : locateOrBuildEntityType( superPersistentClass, context ); } EntityTypeImpl entityType = new EntityTypeImpl( javaType, superType, persistentClass, context.getSessionFactory() ); context.registerEntityType( persistentClass, entityType ); context.popEntityWorkedOn( persistentClass ); return entityType; }
secondPassCompileForeignKeys( referencedClass.getSuperclass().getTable(), done, buildingContext );
: pc.getCustomSQLDeleteCheckStyle(); jk--; pc = pc.getSuperclass();
); else if ( explicitCacheableAnn == null && persistentClass.getSuperclass() != null ) { isCached = persistentClass.getSuperclass().isCached();
inherited = persistentClass.isInherited(); superclass = inherited ? persistentClass.getSuperclass().getEntityName() : null; hasSubclasses = persistentClass.hasSubclasses();
current = current.getSuperclass();
public List<Property> getPropertyClosureForSuperclassFullConstructor(PersistentClass pc) { List<Property> result = new ArrayList<Property>(); if ( pc.getSuperclass() != null ) { // The correct sequence is vital here, as the subclass should be // able to invoke the fullconstructor based on the sequence returned // by this method! result.addAll( getPropertyClosureForSuperclassFullConstructor( pc.getSuperclass() ) ); result.addAll( getPropertiesForFullConstructor( pc.getSuperclass() ) ); } return result; }
protected List<Property> getPropertyClosureForSuperclassMinConstructor(PersistentClass pc) { List<Property> result = new ArrayList<Property>(); if ( pc.getSuperclass() != null ) { // The correct sequence is vital here, as the subclass should be // able to invoke the fullconstructor based on the sequence returned // by this method! result.addAll( getPropertyClosureForSuperclassMinConstructor( pc.getSuperclass() ) ); result.addAll( getPropertiesForMinimalConstructor( pc.getSuperclass() ) ); } return result; }
protected List<Property> getPropertyClosureForSuperclassMinConstructor(PersistentClass pc) { List<Property> result = new ArrayList<Property>(); if ( pc.getSuperclass() != null ) { // The correct sequence is vital here, as the subclass should be // able to invoke the fullconstructor based on the sequence returned // by this method! result.addAll( getPropertyClosureForSuperclassMinConstructor( pc.getSuperclass() ) ); result.addAll( getPropertiesForMinimalConstructor( pc.getSuperclass() ) ); } return result; }
public List<Property> getPropertyClosureForSuperclassFullConstructor(PersistentClass pc) { List<Property> result = new ArrayList<Property>(); if ( pc.getSuperclass() != null ) { // The correct sequence is vital here, as the subclass should be // able to invoke the fullconstructor based on the sequence returned // by this method! result.addAll( getPropertyClosureForSuperclassFullConstructor( pc.getSuperclass() ) ); result.addAll( getPropertiesForFullConstructor( pc.getSuperclass() ) ); } return result; }
public POJOClass getSuperClass(){ if (!isSubclass()) return null; return new EntityPOJOClass(clazz.getSuperclass(),c2j); }
public POJOClass getSuperClass(){ if (!isSubclass()) return null; return new EntityPOJOClass(clazz.getSuperclass(),c2j); }