Search in sources :

Example 1 with Inheritance

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

the class JPAXMLOverriddenAnnotationReader method getInheritance.

private Inheritance getInheritance(ManagedType root, XMLContext.Default defaults) {
    JaxbInheritance element = root instanceof JaxbEntity ? ((JaxbEntity) root).getInheritance() : null;
    if (element != null) {
        AnnotationDescriptor ad = new AnnotationDescriptor(Inheritance.class);
        InheritanceType strategy = element.getStrategy();
        if (strategy != null) {
            ad.setValue("strategy", strategy);
        }
        return AnnotationFactory.create(ad);
    } else if (defaults.canUseJavaAnnotations()) {
        return getPhysicalAnnotation(Inheritance.class);
    } else {
        return null;
    }
}
Also used : AnnotationDescriptor(org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor) JaxbInheritance(org.hibernate.boot.jaxb.mapping.spi.JaxbInheritance) Inheritance(jakarta.persistence.Inheritance) JaxbInheritance(org.hibernate.boot.jaxb.mapping.spi.JaxbInheritance) InheritanceType(jakarta.persistence.InheritanceType) JaxbEntity(org.hibernate.boot.jaxb.mapping.spi.JaxbEntity)

Example 2 with Inheritance

use of jakarta.persistence.Inheritance 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

Inheritance (jakarta.persistence.Inheritance)2 InheritanceType (jakarta.persistence.InheritanceType)1 MappedSuperclass (jakarta.persistence.MappedSuperclass)1 AnnotationDescriptor (org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor)1 XAnnotatedElement (org.hibernate.annotations.common.reflection.XAnnotatedElement)1 JaxbEntity (org.hibernate.boot.jaxb.mapping.spi.JaxbEntity)1 JaxbInheritance (org.hibernate.boot.jaxb.mapping.spi.JaxbInheritance)1