Search in sources :

Example 1 with NamedAttributeNode

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

the class MetamodelImpl method applyNamedAttributeNodes.

private void applyNamedAttributeNodes(NamedAttributeNode[] namedAttributeNodes, NamedEntityGraph namedEntityGraph, AbstractGraphNode graphNode) {
    for (NamedAttributeNode namedAttributeNode : namedAttributeNodes) {
        final String value = namedAttributeNode.value();
        AttributeNodeImpl attributeNode = graphNode.addAttribute(value);
        if (StringHelper.isNotEmpty(namedAttributeNode.subgraph())) {
            final SubgraphImpl subgraph = attributeNode.makeSubgraph();
            applyNamedSubgraphs(namedEntityGraph, namedAttributeNode.subgraph(), subgraph);
        }
        if (StringHelper.isNotEmpty(namedAttributeNode.keySubgraph())) {
            final SubgraphImpl subgraph = attributeNode.makeKeySubgraph();
            applyNamedSubgraphs(namedEntityGraph, namedAttributeNode.keySubgraph(), subgraph);
        }
    }
}
Also used : AttributeNodeImpl(org.hibernate.jpa.graph.internal.AttributeNodeImpl) NamedAttributeNode(javax.persistence.NamedAttributeNode) SubgraphImpl(org.hibernate.jpa.graph.internal.SubgraphImpl)

Example 2 with NamedAttributeNode

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

the class JPAOverriddenAnnotationReader method bindNamedAttributeNodes.

private static void bindNamedAttributeNodes(Element subElement, AnnotationDescriptor ann) {
    List<Element> namedAttributeNodes = subElement.elements("named-attribute-node");
    List<NamedAttributeNode> annNamedAttributeNodes = new ArrayList<>();
    for (Element namedAttributeNode : namedAttributeNodes) {
        AnnotationDescriptor annNamedAttributeNode = new AnnotationDescriptor(NamedAttributeNode.class);
        copyStringAttribute(annNamedAttributeNode, namedAttributeNode, "value", "name", true);
        copyStringAttribute(annNamedAttributeNode, namedAttributeNode, "subgraph", false);
        copyStringAttribute(annNamedAttributeNode, namedAttributeNode, "key-subgraph", false);
        annNamedAttributeNodes.add(AnnotationFactory.create(annNamedAttributeNode));
    }
    ann.setValue("attributeNodes", annNamedAttributeNodes.toArray(new NamedAttributeNode[annNamedAttributeNodes.size()]));
}
Also used : AnnotationDescriptor(org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor) AnnotatedElement(java.lang.reflect.AnnotatedElement) Element(org.dom4j.Element) ArrayList(java.util.ArrayList) NamedAttributeNode(javax.persistence.NamedAttributeNode)

Aggregations

NamedAttributeNode (javax.persistence.NamedAttributeNode)2 AnnotatedElement (java.lang.reflect.AnnotatedElement)1 ArrayList (java.util.ArrayList)1 Element (org.dom4j.Element)1 AnnotationDescriptor (org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor)1 AttributeNodeImpl (org.hibernate.jpa.graph.internal.AttributeNodeImpl)1 SubgraphImpl (org.hibernate.jpa.graph.internal.SubgraphImpl)1