Search in sources :

Example 1 with NamedEntityGraphs

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

the class JPAXMLOverriddenAnnotationReader method getNamedEntityGraphs.

private NamedEntityGraphs getNamedEntityGraphs(ManagedType root, XMLContext.Default defaults) {
    List<NamedEntityGraph> queries = root instanceof JaxbEntity ? buildNamedEntityGraph(((JaxbEntity) root).getNamedEntityGraph(), defaults, classLoaderAccess) : new ArrayList<>();
    if (defaults.canUseJavaAnnotations()) {
        NamedEntityGraph annotation = getPhysicalAnnotation(NamedEntityGraph.class);
        addNamedEntityGraphIfNeeded(annotation, queries);
        NamedEntityGraphs annotations = getPhysicalAnnotation(NamedEntityGraphs.class);
        if (annotations != null) {
            for (NamedEntityGraph current : annotations.value()) {
                addNamedEntityGraphIfNeeded(current, queries);
            }
        }
    }
    if (queries.size() > 0) {
        AnnotationDescriptor ad = new AnnotationDescriptor(NamedEntityGraphs.class);
        ad.setValue("value", queries.toArray(new NamedEntityGraph[queries.size()]));
        return AnnotationFactory.create(ad);
    } else {
        return null;
    }
}
Also used : AnnotationDescriptor(org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor) NamedEntityGraphs(jakarta.persistence.NamedEntityGraphs) NamedEntityGraph(jakarta.persistence.NamedEntityGraph) JaxbNamedEntityGraph(org.hibernate.boot.jaxb.mapping.spi.JaxbNamedEntityGraph) JaxbEntity(org.hibernate.boot.jaxb.mapping.spi.JaxbEntity)

Example 2 with NamedEntityGraphs

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

the class EntityBinder method processNamedEntityGraphs.

private void processNamedEntityGraphs() {
    processNamedEntityGraph(annotatedClass.getAnnotation(NamedEntityGraph.class));
    final NamedEntityGraphs graphs = annotatedClass.getAnnotation(NamedEntityGraphs.class);
    if (graphs != null) {
        for (NamedEntityGraph graph : graphs.value()) {
            processNamedEntityGraph(graph);
        }
    }
}
Also used : NamedEntityGraphs(jakarta.persistence.NamedEntityGraphs) NamedEntityGraph(jakarta.persistence.NamedEntityGraph)

Aggregations

NamedEntityGraph (jakarta.persistence.NamedEntityGraph)2 NamedEntityGraphs (jakarta.persistence.NamedEntityGraphs)2 AnnotationDescriptor (org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor)1 JaxbEntity (org.hibernate.boot.jaxb.mapping.spi.JaxbEntity)1 JaxbNamedEntityGraph (org.hibernate.boot.jaxb.mapping.spi.JaxbNamedEntityGraph)1