use of javax.persistence.NamedQuery 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;
}
}
use of javax.persistence.NamedQuery in project hibernate-orm by hibernate.
the class JPAOverriddenAnnotationReader method addNamedQueryIfNeeded.
private void addNamedQueryIfNeeded(NamedQuery annotation, List<NamedQuery> queries) {
if (annotation != null) {
String queryName = annotation.name();
boolean present = false;
for (NamedQuery current : queries) {
if (current.name().equals(queryName)) {
present = true;
break;
}
}
if (!present) {
queries.add(annotation);
}
}
}
Aggregations