Search in sources :

Example 1 with NamedQueries

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

the class JPAOverriddenAnnotationReader method getNamedQueries.

private NamedQueries getNamedQueries(Element tree, XMLContext.Default defaults) {
    //TODO avoid the Proxy Creation (@NamedQueries) when possible
    List<NamedQuery> queries = (List<NamedQuery>) buildNamedQueries(tree, false, defaults, classLoaderAccess);
    if (defaults.canUseJavaAnnotations()) {
        NamedQuery annotation = getPhysicalAnnotation(NamedQuery.class);
        addNamedQueryIfNeeded(annotation, queries);
        NamedQueries annotations = getPhysicalAnnotation(NamedQueries.class);
        if (annotations != null) {
            for (NamedQuery current : annotations.value()) {
                addNamedQueryIfNeeded(current, queries);
            }
        }
    }
    if (queries.size() > 0) {
        AnnotationDescriptor ad = new AnnotationDescriptor(NamedQueries.class);
        ad.setValue("value", queries.toArray(new NamedQuery[queries.size()]));
        return AnnotationFactory.create(ad);
    } else {
        return null;
    }
}
Also used : AnnotationDescriptor(org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor) ArrayList(java.util.ArrayList) List(java.util.List) NamedQueries(javax.persistence.NamedQueries) NamedQuery(javax.persistence.NamedQuery)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 NamedQueries (javax.persistence.NamedQueries)1 NamedQuery (javax.persistence.NamedQuery)1 AnnotationDescriptor (org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor)1