Search in sources :

Example 1 with NamedSubgraph

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

the class JPAXMLOverriddenAnnotationReader method bindNamedSubgraph.

private static void bindNamedSubgraph(XMLContext.Default defaults, AnnotationDescriptor ann, String annotationAttributeName, List<JaxbNamedSubgraph> subgraphNodes, ClassLoaderAccess classLoaderAccess) {
    List<NamedSubgraph> annSubgraphNodes = new ArrayList<>();
    for (JaxbNamedSubgraph subgraphNode : subgraphNodes) {
        AnnotationDescriptor annSubgraphNode = new AnnotationDescriptor(NamedSubgraph.class);
        copyAttribute(annSubgraphNode, "name", subgraphNode.getName(), true);
        String clazzName = subgraphNode.getClazz();
        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.getNamedAttributeNode(), annSubgraphNode);
        annSubgraphNodes.add(AnnotationFactory.create(annSubgraphNode));
    }
    ann.setValue(annotationAttributeName, annSubgraphNodes.toArray(new NamedSubgraph[annSubgraphNodes.size()]));
}
Also used : NamedSubgraph(jakarta.persistence.NamedSubgraph) JaxbNamedSubgraph(org.hibernate.boot.jaxb.mapping.spi.JaxbNamedSubgraph) AnnotationDescriptor(org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor) JaxbNamedSubgraph(org.hibernate.boot.jaxb.mapping.spi.JaxbNamedSubgraph) ClassLoadingException(org.hibernate.boot.registry.classloading.spi.ClassLoadingException) ArrayList(java.util.ArrayList) AnnotationException(org.hibernate.AnnotationException) IdClass(jakarta.persistence.IdClass) MapKeyClass(jakarta.persistence.MapKeyClass) JaxbIdClass(org.hibernate.boot.jaxb.mapping.spi.JaxbIdClass) JaxbMapKeyClass(org.hibernate.boot.jaxb.mapping.spi.JaxbMapKeyClass)

Aggregations

IdClass (jakarta.persistence.IdClass)1 MapKeyClass (jakarta.persistence.MapKeyClass)1 NamedSubgraph (jakarta.persistence.NamedSubgraph)1 ArrayList (java.util.ArrayList)1 AnnotationException (org.hibernate.AnnotationException)1 AnnotationDescriptor (org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor)1 JaxbIdClass (org.hibernate.boot.jaxb.mapping.spi.JaxbIdClass)1 JaxbMapKeyClass (org.hibernate.boot.jaxb.mapping.spi.JaxbMapKeyClass)1 JaxbNamedSubgraph (org.hibernate.boot.jaxb.mapping.spi.JaxbNamedSubgraph)1 ClassLoadingException (org.hibernate.boot.registry.classloading.spi.ClassLoadingException)1