Search in sources :

Example 1 with NamedSubgraph

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

the class JPAOverriddenAnnotationReader method bindNamedSubgraph.

private static void bindNamedSubgraph(XMLContext.Default defaults, AnnotationDescriptor ann, List<Element> subgraphNodes, ClassLoaderAccess classLoaderAccess) {
    List<NamedSubgraph> annSubgraphNodes = new ArrayList<NamedSubgraph>();
    for (Element subgraphNode : subgraphNodes) {
        AnnotationDescriptor annSubgraphNode = new AnnotationDescriptor(NamedSubgraph.class);
        copyStringAttribute(annSubgraphNode, subgraphNode, "name", true);
        String clazzName = subgraphNode.attributeValue("class");
        Class clazz;
        try {
            clazz = classLoaderAccess.classForName(XMLContext.buildSafeClassName(clazzName, defaults));
        } catch (ClassLoadingException e) {
            throw new AnnotationException("Unable to find entity-class: " + clazzName, e);
        }
        annSubgraphNode.setValue("type", clazz);
        bindNamedAttributeNodes(subgraphNode, annSubgraphNode);
        annSubgraphNodes.add((NamedSubgraph) AnnotationFactory.create(annSubgraphNode));
    }
    ann.setValue("subgraphs", annSubgraphNodes.toArray(new NamedSubgraph[annSubgraphNodes.size()]));
}
Also used : NamedSubgraph(javax.persistence.NamedSubgraph) AnnotationDescriptor(org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor) ClassLoadingException(org.hibernate.boot.registry.classloading.spi.ClassLoadingException) AnnotatedElement(java.lang.reflect.AnnotatedElement) Element(org.dom4j.Element) ArrayList(java.util.ArrayList) AnnotationException(org.hibernate.AnnotationException) MapKeyClass(javax.persistence.MapKeyClass) IdClass(javax.persistence.IdClass)

Aggregations

AnnotatedElement (java.lang.reflect.AnnotatedElement)1 ArrayList (java.util.ArrayList)1 IdClass (javax.persistence.IdClass)1 MapKeyClass (javax.persistence.MapKeyClass)1 NamedSubgraph (javax.persistence.NamedSubgraph)1 Element (org.dom4j.Element)1 AnnotationException (org.hibernate.AnnotationException)1 AnnotationDescriptor (org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor)1 ClassLoadingException (org.hibernate.boot.registry.classloading.spi.ClassLoadingException)1