use of org.hibernate.boot.jaxb.mapping.spi.JaxbEntity 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 org.hibernate.boot.jaxb.mapping.spi.JaxbEntity in project hibernate-orm by hibernate.
the class JPAXMLOverriddenAnnotationReader method getNamedEntityGraphs.
private NamedEntityGraphs getNamedEntityGraphs(ManagedType root, XMLContext.Default defaults) {
List<NamedEntityGraph> queries = root instanceof JaxbEntity ? buildNamedEntityGraph(((JaxbEntity) root).getNamedEntityGraph(), defaults, classLoaderAccess) : new ArrayList<>();
if (defaults.canUseJavaAnnotations()) {
NamedEntityGraph annotation = getPhysicalAnnotation(NamedEntityGraph.class);
addNamedEntityGraphIfNeeded(annotation, queries);
NamedEntityGraphs annotations = getPhysicalAnnotation(NamedEntityGraphs.class);
if (annotations != null) {
for (NamedEntityGraph current : annotations.value()) {
addNamedEntityGraphIfNeeded(current, queries);
}
}
}
if (queries.size() > 0) {
AnnotationDescriptor ad = new AnnotationDescriptor(NamedEntityGraphs.class);
ad.setValue("value", queries.toArray(new NamedEntityGraph[queries.size()]));
return AnnotationFactory.create(ad);
} else {
return null;
}
}
use of org.hibernate.boot.jaxb.mapping.spi.JaxbEntity 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;
}
}
use of org.hibernate.boot.jaxb.mapping.spi.JaxbEntity in project hibernate-orm by hibernate.
the class JPAXMLOverriddenAnnotationReader method getSqlResultSetMappings.
private SqlResultSetMappings getSqlResultSetMappings(ManagedType root, XMLContext.Default defaults) {
List<SqlResultSetMapping> results = root instanceof JaxbEntity ? buildSqlResultsetMappings(((JaxbEntity) root).getSqlResultSetMapping(), defaults, classLoaderAccess) : new ArrayList<>();
if (defaults.canUseJavaAnnotations()) {
SqlResultSetMapping annotation = getPhysicalAnnotation(SqlResultSetMapping.class);
addSqlResultsetMappingIfNeeded(annotation, results);
SqlResultSetMappings annotations = getPhysicalAnnotation(SqlResultSetMappings.class);
if (annotations != null) {
for (SqlResultSetMapping current : annotations.value()) {
addSqlResultsetMappingIfNeeded(current, results);
}
}
}
if (results.size() > 0) {
AnnotationDescriptor ad = new AnnotationDescriptor(SqlResultSetMappings.class);
ad.setValue("value", results.toArray(new SqlResultSetMapping[results.size()]));
return AnnotationFactory.create(ad);
} else {
return null;
}
}
use of org.hibernate.boot.jaxb.mapping.spi.JaxbEntity in project hibernate-orm by hibernate.
the class JPAXMLOverriddenAnnotationReader method getInheritance.
private Inheritance getInheritance(ManagedType root, XMLContext.Default defaults) {
JaxbInheritance element = root instanceof JaxbEntity ? ((JaxbEntity) root).getInheritance() : null;
if (element != null) {
AnnotationDescriptor ad = new AnnotationDescriptor(Inheritance.class);
InheritanceType strategy = element.getStrategy();
if (strategy != null) {
ad.setValue("strategy", strategy);
}
return AnnotationFactory.create(ad);
} else if (defaults.canUseJavaAnnotations()) {
return getPhysicalAnnotation(Inheritance.class);
} else {
return null;
}
}
Aggregations