use of org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor in project hibernate-orm by hibernate.
the class JPAOverriddenAnnotationReader method getOrderBy.
private void getOrderBy(List<Annotation> annotationList, Element element) {
Element subelement = element != null ? element.element("order-by") : null;
if (subelement != null) {
AnnotationDescriptor ad = new AnnotationDescriptor(OrderBy.class);
copyStringElement(subelement, ad, "value");
annotationList.add(AnnotationFactory.create(ad));
}
}
use of org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor in project hibernate-orm by hibernate.
the class JPAOverriddenAnnotationReader method buildTableGeneratorAnnotation.
public static TableGenerator buildTableGeneratorAnnotation(Element element, XMLContext.Default defaults) {
AnnotationDescriptor ad = new AnnotationDescriptor(TableGenerator.class);
copyStringAttribute(ad, element, "name", false);
copyStringAttribute(ad, element, "table", false);
copyStringAttribute(ad, element, "catalog", false);
copyStringAttribute(ad, element, "schema", false);
copyStringAttribute(ad, element, "pk-column-name", false);
copyStringAttribute(ad, element, "value-column-name", false);
copyStringAttribute(ad, element, "pk-column-value", false);
copyIntegerAttribute(ad, element, "initial-value");
copyIntegerAttribute(ad, element, "allocation-size");
buildUniqueConstraints(ad, element);
if (StringHelper.isEmpty((String) ad.valueOf("schema")) && StringHelper.isNotEmpty(defaults.getSchema())) {
ad.setValue("schema", defaults.getSchema());
}
if (StringHelper.isEmpty((String) ad.valueOf("catalog")) && StringHelper.isNotEmpty(defaults.getCatalog())) {
ad.setValue("catalog", defaults.getCatalog());
}
return AnnotationFactory.create(ad);
}
use of org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor in project hibernate-orm by hibernate.
the class JPAOverriddenAnnotationReader method getMapKey.
private void getMapKey(List<Annotation> annotationList, Element element) {
Element subelement = element != null ? element.element("map-key") : null;
if (subelement != null) {
AnnotationDescriptor ad = new AnnotationDescriptor(MapKey.class);
copyStringAttribute(ad, subelement, "name", false);
annotationList.add(AnnotationFactory.create(ad));
}
}
use of org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor in project hibernate-orm by hibernate.
the class JPAOverriddenAnnotationReader method processEventAnnotations.
private void processEventAnnotations(List<Annotation> annotationList, XMLContext.Default defaults) {
boolean eventElement = false;
for (Element element : elementsForProperty) {
String elementName = element.getName();
if ("pre-persist".equals(elementName)) {
AnnotationDescriptor ad = new AnnotationDescriptor(PrePersist.class);
annotationList.add(AnnotationFactory.create(ad));
eventElement = true;
} else if ("pre-remove".equals(elementName)) {
AnnotationDescriptor ad = new AnnotationDescriptor(PreRemove.class);
annotationList.add(AnnotationFactory.create(ad));
eventElement = true;
} else if ("pre-update".equals(elementName)) {
AnnotationDescriptor ad = new AnnotationDescriptor(PreUpdate.class);
annotationList.add(AnnotationFactory.create(ad));
eventElement = true;
} else if ("post-persist".equals(elementName)) {
AnnotationDescriptor ad = new AnnotationDescriptor(PostPersist.class);
annotationList.add(AnnotationFactory.create(ad));
eventElement = true;
} else if ("post-remove".equals(elementName)) {
AnnotationDescriptor ad = new AnnotationDescriptor(PostRemove.class);
annotationList.add(AnnotationFactory.create(ad));
eventElement = true;
} else if ("post-update".equals(elementName)) {
AnnotationDescriptor ad = new AnnotationDescriptor(PostUpdate.class);
annotationList.add(AnnotationFactory.create(ad));
eventElement = true;
} else if ("post-load".equals(elementName)) {
AnnotationDescriptor ad = new AnnotationDescriptor(PostLoad.class);
annotationList.add(AnnotationFactory.create(ad));
eventElement = true;
}
}
if (!eventElement && defaults.canUseJavaAnnotations()) {
Annotation ann = getPhysicalAnnotation(PrePersist.class);
addIfNotNull(annotationList, ann);
ann = getPhysicalAnnotation(PreRemove.class);
addIfNotNull(annotationList, ann);
ann = getPhysicalAnnotation(PreUpdate.class);
addIfNotNull(annotationList, ann);
ann = getPhysicalAnnotation(PostPersist.class);
addIfNotNull(annotationList, ann);
ann = getPhysicalAnnotation(PostRemove.class);
addIfNotNull(annotationList, ann);
ann = getPhysicalAnnotation(PostUpdate.class);
addIfNotNull(annotationList, ann);
ann = getPhysicalAnnotation(PostLoad.class);
addIfNotNull(annotationList, ann);
}
}
use of org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor in project hibernate-orm by hibernate.
the class JPAOverriddenAnnotationReader method getOrderColumn.
/**
* Adds an @OrderColumn annotation to the specified annotationList if the specified element
* contains an order-column sub-element. This should only be the case for element-collection,
* many-to-many, or one-to-many associations.
*/
private void getOrderColumn(List<Annotation> annotationList, Element element) {
Element subelement = element != null ? element.element("order-column") : null;
if (subelement != null) {
AnnotationDescriptor ad = new AnnotationDescriptor(OrderColumn.class);
copyStringAttribute(ad, subelement, "name", false);
copyBooleanAttribute(ad, subelement, "nullable");
copyBooleanAttribute(ad, subelement, "insertable");
copyBooleanAttribute(ad, subelement, "updatable");
copyStringAttribute(ad, subelement, "column-definition", false);
annotationList.add(AnnotationFactory.create(ad));
}
}
Aggregations