use of org.hibernate.boot.jaxb.mapping.spi.JaxbEntity in project hibernate-orm by hibernate.
the class JPAXMLOverriddenAnnotationReader method getNamedStoredProcedureQueries.
private NamedStoredProcedureQueries getNamedStoredProcedureQueries(ManagedType root, XMLContext.Default defaults) {
List<NamedStoredProcedureQuery> queries = root instanceof JaxbEntity ? buildNamedStoreProcedureQueries(((JaxbEntity) root).getNamedStoredProcedureQuery(), defaults, classLoaderAccess) : new ArrayList<>();
if (defaults.canUseJavaAnnotations()) {
NamedStoredProcedureQuery annotation = getPhysicalAnnotation(NamedStoredProcedureQuery.class);
addNamedStoredProcedureQueryIfNeeded(annotation, queries);
NamedStoredProcedureQueries annotations = getPhysicalAnnotation(NamedStoredProcedureQueries.class);
if (annotations != null) {
for (NamedStoredProcedureQuery current : annotations.value()) {
addNamedStoredProcedureQueryIfNeeded(current, queries);
}
}
}
if (queries.size() > 0) {
AnnotationDescriptor ad = new AnnotationDescriptor(NamedStoredProcedureQueries.class);
ad.setValue("value", queries.toArray(new NamedStoredProcedureQuery[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 getTable.
private Table getTable(ManagedType root, XMLContext.Default defaults) {
JaxbTable element = root instanceof JaxbEntity ? ((JaxbEntity) root).getTable() : null;
if (element == null) {
// no element but might have some default or some annotation
if (StringHelper.isNotEmpty(defaults.getCatalog()) || StringHelper.isNotEmpty(defaults.getSchema())) {
AnnotationDescriptor annotation = new AnnotationDescriptor(Table.class);
if (defaults.canUseJavaAnnotations()) {
Table table = getPhysicalAnnotation(Table.class);
if (table != null) {
annotation.setValue("name", table.name());
annotation.setValue("schema", table.schema());
annotation.setValue("catalog", table.catalog());
annotation.setValue("uniqueConstraints", table.uniqueConstraints());
annotation.setValue("indexes", table.indexes());
}
}
if (StringHelper.isEmpty((String) annotation.valueOf("schema")) && StringHelper.isNotEmpty(defaults.getSchema())) {
annotation.setValue("schema", defaults.getSchema());
}
if (StringHelper.isEmpty((String) annotation.valueOf("catalog")) && StringHelper.isNotEmpty(defaults.getCatalog())) {
annotation.setValue("catalog", defaults.getCatalog());
}
return AnnotationFactory.create(annotation);
} else if (defaults.canUseJavaAnnotations()) {
return getPhysicalAnnotation(Table.class);
} else {
return null;
}
} else {
// ignore java annotation, an element is defined
AnnotationDescriptor annotation = new AnnotationDescriptor(Table.class);
copyAttribute(annotation, "name", element.getName(), false);
copyAttribute(annotation, "catalog", element.getCatalog(), false);
if (StringHelper.isNotEmpty(defaults.getCatalog()) && StringHelper.isEmpty((String) annotation.valueOf("catalog"))) {
annotation.setValue("catalog", defaults.getCatalog());
}
copyAttribute(annotation, "schema", element.getSchema(), false);
if (StringHelper.isNotEmpty(defaults.getSchema()) && StringHelper.isEmpty((String) annotation.valueOf("schema"))) {
annotation.setValue("schema", defaults.getSchema());
}
buildUniqueConstraints(annotation, element.getUniqueConstraint());
buildIndex(annotation, element.getIndex());
return AnnotationFactory.create(annotation);
}
}
use of org.hibernate.boot.jaxb.mapping.spi.JaxbEntity in project hibernate-orm by hibernate.
the class JPAXMLOverriddenAnnotationReader method getEntity.
private Entity getEntity(ManagedType element, XMLContext.Default defaults) {
if (element == null) {
return defaults.canUseJavaAnnotations() ? getPhysicalAnnotation(Entity.class) : null;
} else {
if (element instanceof JaxbEntity) {
JaxbEntity entityElement = (JaxbEntity) element;
AnnotationDescriptor entity = new AnnotationDescriptor(Entity.class);
copyAttribute(entity, "name", entityElement.getName(), false);
if (defaults.canUseJavaAnnotations() && StringHelper.isEmpty((String) entity.valueOf("name"))) {
Entity javaAnn = getPhysicalAnnotation(Entity.class);
if (javaAnn != null) {
entity.setValue("name", javaAnn.name());
}
}
return AnnotationFactory.create(entity);
} else {
// this is not an entity
return null;
}
}
}
use of org.hibernate.boot.jaxb.mapping.spi.JaxbEntity in project hibernate-orm by hibernate.
the class JPAXMLOverriddenAnnotationReader method getDiscriminatorValue.
private DiscriminatorValue getDiscriminatorValue(ManagedType root, XMLContext.Default defaults) {
String element = root instanceof JaxbEntity ? ((JaxbEntity) root).getDiscriminatorValue() : null;
if (element != null) {
AnnotationDescriptor ad = new AnnotationDescriptor(DiscriminatorValue.class);
ad.setValue("value", element);
return AnnotationFactory.create(ad);
} else if (defaults.canUseJavaAnnotations()) {
return getPhysicalAnnotation(DiscriminatorValue.class);
} else {
return null;
}
}
use of org.hibernate.boot.jaxb.mapping.spi.JaxbEntity in project hibernate-orm by hibernate.
the class JPAXMLOverriddenAnnotationReader method getCacheable.
private Cacheable getCacheable(ManagedType root, XMLContext.Default defaults) {
if (root instanceof JaxbEntity) {
Boolean attValue = ((JaxbEntity) root).isCacheable();
if (attValue != null) {
AnnotationDescriptor ad = new AnnotationDescriptor(Cacheable.class);
ad.setValue("value", attValue);
return AnnotationFactory.create(ad);
}
}
if (defaults.canUseJavaAnnotations()) {
return getPhysicalAnnotation(Cacheable.class);
} else {
return null;
}
}
Aggregations