use of org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor in project hibernate-orm by hibernate.
the class JPAOverriddenAnnotationReader method buildIndex.
private static void buildIndex(AnnotationDescriptor annotation, Element element) {
List indexElementList = element.elements("index");
Index[] indexes = new Index[indexElementList.size()];
for (int i = 0; i < indexElementList.size(); i++) {
Element subelement = (Element) indexElementList.get(i);
AnnotationDescriptor indexAnn = new AnnotationDescriptor(Index.class);
copyStringAttribute(indexAnn, subelement, "name", false);
copyStringAttribute(indexAnn, subelement, "column-list", true);
copyBooleanAttribute(indexAnn, subelement, "unique");
indexes[i] = AnnotationFactory.create(indexAnn);
}
annotation.setValue("indexes", indexes);
}
use of org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor in project hibernate-orm by hibernate.
the class JPAOverriddenAnnotationReader method getInheritance.
private Inheritance getInheritance(Element tree, XMLContext.Default defaults) {
Element element = tree != null ? tree.element("inheritance") : null;
if (element != null) {
AnnotationDescriptor ad = new AnnotationDescriptor(Inheritance.class);
Attribute attr = element.attribute("strategy");
InheritanceType strategy = InheritanceType.SINGLE_TABLE;
if (attr != null) {
String value = attr.getValue();
if ("SINGLE_TABLE".equals(value)) {
strategy = InheritanceType.SINGLE_TABLE;
} else if ("JOINED".equals(value)) {
strategy = InheritanceType.JOINED;
} else if ("TABLE_PER_CLASS".equals(value)) {
strategy = InheritanceType.TABLE_PER_CLASS;
} else {
throw new AnnotationException("Unknown InheritanceType in XML: " + value + " (" + SCHEMA_VALIDATION + ")");
}
}
ad.setValue("strategy", strategy);
return AnnotationFactory.create(ad);
} else if (defaults.canUseJavaAnnotations()) {
return getPhysicalAnnotation(Inheritance.class);
} else {
return null;
}
}
use of org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor in project hibernate-orm by hibernate.
the class JPAOverriddenAnnotationReader method getCollectionTable.
private void getCollectionTable(List<Annotation> annotationList, Element element, XMLContext.Default defaults) {
Element subelement = element != null ? element.element("collection-table") : null;
if (subelement != null) {
AnnotationDescriptor annotation = new AnnotationDescriptor(CollectionTable.class);
copyStringAttribute(annotation, subelement, "name", false);
copyStringAttribute(annotation, subelement, "catalog", false);
if (StringHelper.isNotEmpty(defaults.getCatalog()) && StringHelper.isEmpty((String) annotation.valueOf("catalog"))) {
annotation.setValue("catalog", defaults.getCatalog());
}
copyStringAttribute(annotation, subelement, "schema", false);
if (StringHelper.isNotEmpty(defaults.getSchema()) && StringHelper.isEmpty((String) annotation.valueOf("schema"))) {
annotation.setValue("schema", defaults.getSchema());
}
JoinColumn[] joinColumns = getJoinColumns(subelement, false);
if (joinColumns.length > 0) {
annotation.setValue("joinColumns", joinColumns);
}
buildUniqueConstraints(annotation, subelement);
buildIndex(annotation, subelement);
annotationList.add(AnnotationFactory.create(annotation));
}
}
use of org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor in project hibernate-orm by hibernate.
the class JPAOverriddenAnnotationReader method buildJoinColumns.
private void buildJoinColumns(List<Annotation> annotationList, Element element) {
JoinColumn[] joinColumns = getJoinColumns(element, false);
if (joinColumns.length > 0) {
AnnotationDescriptor ad = new AnnotationDescriptor(JoinColumns.class);
ad.setValue("value", joinColumns);
annotationList.add(AnnotationFactory.create(ad));
}
}
use of org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor in project hibernate-orm by hibernate.
the class JPAOverriddenAnnotationReader method getCacheable.
private Cacheable getCacheable(Element element, XMLContext.Default defaults) {
if (element != null) {
String attValue = element.attributeValue("cacheable");
if (attValue != null) {
AnnotationDescriptor ad = new AnnotationDescriptor(Cacheable.class);
ad.setValue("value", Boolean.valueOf(attValue));
return AnnotationFactory.create(ad);
}
}
if (defaults.canUseJavaAnnotations()) {
return getPhysicalAnnotation(Cacheable.class);
} else {
return null;
}
}
Aggregations