use of jakarta.persistence.NamedQueries in project hibernate-orm by hibernate.
the class JPAXMLOverriddenAnnotationReader method getNamedQueries.
private NamedQueries getNamedQueries(ManagedType root, XMLContext.Default defaults) {
// TODO avoid the Proxy Creation (@NamedQueries) when possible
List<NamedQuery> queries = root instanceof JaxbEntity ? buildNamedQueries(((JaxbEntity) root).getNamedQuery(), defaults, classLoaderAccess) : new ArrayList<>();
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 jakarta.persistence.NamedQueries in project eclipselink by eclipse-ee4j.
the class JavaEntity method buildQueries.
protected Map<String, IQuery> buildQueries() {
Map<String, IQuery> queries = new HashMap<>();
try {
Class<?> type = getType().getType();
Annotation[] annotations = type.getAnnotations();
NamedQueries namedQueries = getAnnotation(annotations, NamedQueries.class);
if (namedQueries != null) {
for (NamedQuery namedQuery : namedQueries.value()) {
IQuery query = buildQuery(namedQuery);
queries.put(namedQuery.name(), query);
}
} else {
NamedQuery namedQuery = getAnnotation(annotations, NamedQuery.class);
if (namedQuery != null) {
IQuery query = buildQuery(namedQuery);
queries.put(namedQuery.name(), query);
}
}
} catch (Exception e) {
// Ignore
}
return queries;
}
Aggregations