Search in sources :

Example 1 with InheritanceType

use of javax.persistence.InheritanceType in project hibernate-orm by hibernate.

the class JPAOverriddenAnnotationReader method getInheritance.

private Inheritance getInheritance(Element tree, XMLContext.Default defaults) {
    Element element = tree != null ? tree.element("inheritance") : null;
    if (element != null) {
        AnnotationDescriptor ad = new AnnotationDescriptor(Inheritance.class);
        Attribute attr = element.attribute("strategy");
        InheritanceType strategy = InheritanceType.SINGLE_TABLE;
        if (attr != null) {
            String value = attr.getValue();
            if ("SINGLE_TABLE".equals(value)) {
                strategy = InheritanceType.SINGLE_TABLE;
            } else if ("JOINED".equals(value)) {
                strategy = InheritanceType.JOINED;
            } else if ("TABLE_PER_CLASS".equals(value)) {
                strategy = InheritanceType.TABLE_PER_CLASS;
            } else {
                throw new AnnotationException("Unknown InheritanceType in XML: " + value + " (" + SCHEMA_VALIDATION + ")");
            }
        }
        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) Attribute(org.dom4j.Attribute) AnnotatedElement(java.lang.reflect.AnnotatedElement) Element(org.dom4j.Element) Inheritance(javax.persistence.Inheritance) AnnotationException(org.hibernate.AnnotationException) InheritanceType(javax.persistence.InheritanceType)

Aggregations

AnnotatedElement (java.lang.reflect.AnnotatedElement)1 Inheritance (javax.persistence.Inheritance)1 InheritanceType (javax.persistence.InheritanceType)1 Attribute (org.dom4j.Attribute)1 Element (org.dom4j.Element)1 AnnotationException (org.hibernate.AnnotationException)1 AnnotationDescriptor (org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor)1