Search in sources :

Example 1 with MappedSuperclass

use of jakarta.persistence.MappedSuperclass in project hibernate-orm by hibernate.

the class AnnotationMetadataSourceProcessorImpl method insertMappedSuperclasses.

private void insertMappedSuperclasses(List<XClass> original, List<XClass> copy) {
    final boolean debug = log.isDebugEnabled();
    for (XClass clazz : original) {
        if (clazz.isAnnotationPresent(jakarta.persistence.MappedSuperclass.class)) {
            if (debug) {
                log.debugf("Skipping explicit MappedSuperclass %s, the class will be discovered analyzing the implementing class", clazz);
            }
        } else {
            copy.add(clazz);
            XClass superClass = clazz.getSuperclass();
            while (superClass != null && !reflectionManager.equals(superClass, Object.class) && !copy.contains(superClass)) {
                if (superClass.isAnnotationPresent(Entity.class) || superClass.isAnnotationPresent(jakarta.persistence.MappedSuperclass.class)) {
                    copy.add(superClass);
                }
                superClass = superClass.getSuperclass();
            }
        }
    }
}
Also used : Entity(jakarta.persistence.Entity) MappedSuperclass(jakarta.persistence.MappedSuperclass) XClass(org.hibernate.annotations.common.reflection.XClass)

Example 2 with MappedSuperclass

use of jakarta.persistence.MappedSuperclass in project hibernate-orm by hibernate.

the class InheritanceState method extractInheritanceType.

private void extractInheritanceType() {
    XAnnotatedElement element = getClazz();
    Inheritance inhAnn = element.getAnnotation(Inheritance.class);
    MappedSuperclass mappedSuperClass = element.getAnnotation(MappedSuperclass.class);
    if (mappedSuperClass != null) {
        setEmbeddableSuperclass(true);
        setType(inhAnn == null ? null : inhAnn.strategy());
    } else {
        setType(inhAnn == null ? InheritanceType.SINGLE_TABLE : inhAnn.strategy());
    }
}
Also used : Inheritance(jakarta.persistence.Inheritance) MappedSuperclass(jakarta.persistence.MappedSuperclass) XAnnotatedElement(org.hibernate.annotations.common.reflection.XAnnotatedElement)

Aggregations

MappedSuperclass (jakarta.persistence.MappedSuperclass)2 Entity (jakarta.persistence.Entity)1 Inheritance (jakarta.persistence.Inheritance)1 XAnnotatedElement (org.hibernate.annotations.common.reflection.XAnnotatedElement)1 XClass (org.hibernate.annotations.common.reflection.XClass)1