Search in sources :

Example 1 with JaxbNamedNativeQuery

use of org.hibernate.boot.jaxb.mapping.spi.JaxbNamedNativeQuery in project hibernate-orm by hibernate.

the class JPAXMLOverriddenAnnotationReader method buildNamedNativeQueries.

public static List<NamedNativeQuery> buildNamedNativeQueries(List<JaxbNamedNativeQuery> elements, XMLContext.Default defaults, ClassLoaderAccess classLoaderAccess) {
    List<NamedNativeQuery> namedQueries = new ArrayList<>();
    for (JaxbNamedNativeQuery element : elements) {
        AnnotationDescriptor ann = new AnnotationDescriptor(NamedNativeQuery.class);
        copyAttribute(ann, "name", element.getName(), false);
        copyAttribute(ann, "query", element.getQuery(), true);
        buildQueryHints(element.getHint(), ann);
        String clazzName = element.getResultClass();
        if (StringHelper.isNotEmpty(clazzName)) {
            Class clazz;
            try {
                clazz = classLoaderAccess.classForName(XMLContext.buildSafeClassName(clazzName, defaults));
            } catch (ClassLoadingException e) {
                throw new AnnotationException("Unable to find entity-class: " + clazzName, e);
            }
            ann.setValue("resultClass", clazz);
        }
        copyAttribute(ann, "result-set-mapping", element.getResultSetMapping(), false);
        namedQueries.add(AnnotationFactory.create(ann));
    }
    return namedQueries;
}
Also used : AnnotationDescriptor(org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor) JaxbNamedNativeQuery(org.hibernate.boot.jaxb.mapping.spi.JaxbNamedNativeQuery) NamedNativeQuery(jakarta.persistence.NamedNativeQuery) ClassLoadingException(org.hibernate.boot.registry.classloading.spi.ClassLoadingException) JaxbNamedNativeQuery(org.hibernate.boot.jaxb.mapping.spi.JaxbNamedNativeQuery) 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 NamedNativeQuery (jakarta.persistence.NamedNativeQuery)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 JaxbNamedNativeQuery (org.hibernate.boot.jaxb.mapping.spi.JaxbNamedNativeQuery)1 ClassLoadingException (org.hibernate.boot.registry.classloading.spi.ClassLoadingException)1