Search in sources :

Example 1 with NamedNativeQueries

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

the class JPAXMLOverriddenAnnotationReader method getNamedNativeQueries.

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

Aggregations

NamedNativeQueries (jakarta.persistence.NamedNativeQueries)1 NamedNativeQuery (jakarta.persistence.NamedNativeQuery)1 AnnotationDescriptor (org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor)1 JaxbEntity (org.hibernate.boot.jaxb.mapping.spi.JaxbEntity)1 JaxbNamedNativeQuery (org.hibernate.boot.jaxb.mapping.spi.JaxbNamedNativeQuery)1