use of org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor in project hibernate-orm by hibernate.
the class JPAOverriddenAnnotationReader method getTemporal.
private void getTemporal(List<Annotation> annotationList, Element element) {
Element subElement = element != null ? element.element("temporal") : null;
if (subElement != null) {
AnnotationDescriptor ad = new AnnotationDescriptor(Temporal.class);
String temporal = subElement.getTextTrim();
if ("DATE".equalsIgnoreCase(temporal)) {
ad.setValue("value", TemporalType.DATE);
} else if ("TIME".equalsIgnoreCase(temporal)) {
ad.setValue("value", TemporalType.TIME);
} else if ("TIMESTAMP".equalsIgnoreCase(temporal)) {
ad.setValue("value", TemporalType.TIMESTAMP);
} else if (StringHelper.isNotEmpty(temporal)) {
throw new AnnotationException("Unknown TemporalType: " + temporal + ". " + SCHEMA_VALIDATION);
}
annotationList.add(AnnotationFactory.create(ad));
}
}
use of org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor in project hibernate-orm by hibernate.
the class JPAOverriddenAnnotationReader method getNamedStoredProcedureQueries.
private NamedStoredProcedureQueries getNamedStoredProcedureQueries(Element tree, XMLContext.Default defaults) {
List<NamedStoredProcedureQuery> queries = buildNamedStoreProcedureQueries(tree, defaults, classLoaderAccess);
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.annotations.common.annotationfactory.AnnotationDescriptor in project hibernate-orm by hibernate.
the class JPAOverriddenAnnotationReader method getMapKeyColumn.
private void getMapKeyColumn(List<Annotation> annotationList, Element element) {
Element subelement = element != null ? element.element("map-key-column") : null;
if (subelement != null) {
AnnotationDescriptor ad = new AnnotationDescriptor(MapKeyColumn.class);
copyStringAttribute(ad, subelement, "name", false);
copyBooleanAttribute(ad, subelement, "unique");
copyBooleanAttribute(ad, subelement, "nullable");
copyBooleanAttribute(ad, subelement, "insertable");
copyBooleanAttribute(ad, subelement, "updatable");
copyStringAttribute(ad, subelement, "column-definition", false);
copyStringAttribute(ad, subelement, "table", false);
copyIntegerAttribute(ad, subelement, "length");
copyIntegerAttribute(ad, subelement, "precision");
copyIntegerAttribute(ad, subelement, "scale");
annotationList.add(AnnotationFactory.create(ad));
}
}
use of org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor in project hibernate-orm by hibernate.
the class JPAOverriddenAnnotationReader method buildUniqueConstraints.
private static void buildUniqueConstraints(AnnotationDescriptor annotation, Element element) {
List uniqueConstraintElementList = element.elements("unique-constraint");
UniqueConstraint[] uniqueConstraints = new UniqueConstraint[uniqueConstraintElementList.size()];
int ucIndex = 0;
Iterator ucIt = uniqueConstraintElementList.listIterator();
while (ucIt.hasNext()) {
Element subelement = (Element) ucIt.next();
List<Element> columnNamesElements = subelement.elements("column-name");
String[] columnNames = new String[columnNamesElements.size()];
int columnNameIndex = 0;
Iterator it = columnNamesElements.listIterator();
while (it.hasNext()) {
Element columnNameElt = (Element) it.next();
columnNames[columnNameIndex++] = columnNameElt.getTextTrim();
}
AnnotationDescriptor ucAnn = new AnnotationDescriptor(UniqueConstraint.class);
copyStringAttribute(ucAnn, subelement, "name", false);
ucAnn.setValue("columnNames", columnNames);
uniqueConstraints[ucIndex++] = AnnotationFactory.create(ucAnn);
}
annotation.setValue("uniqueConstraints", uniqueConstraints);
}
use of org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor in project hibernate-orm by hibernate.
the class JPAOverriddenAnnotationReader method getEmbeddedId.
private void getEmbeddedId(List<Annotation> annotationList, XMLContext.Default defaults) {
for (Element element : elementsForProperty) {
if ("embedded-id".equals(element.getName())) {
if (isProcessingId(defaults)) {
Annotation annotation = getAttributeOverrides(element, defaults, false);
addIfNotNull(annotationList, annotation);
annotation = getAssociationOverrides(element, defaults, false);
addIfNotNull(annotationList, annotation);
AnnotationDescriptor ad = new AnnotationDescriptor(EmbeddedId.class);
annotationList.add(AnnotationFactory.create(ad));
getAccessType(annotationList, element);
}
}
}
if (elementsForProperty.size() == 0 && defaults.canUseJavaAnnotations()) {
Annotation annotation = getPhysicalAnnotation(EmbeddedId.class);
if (annotation != null) {
annotationList.add(annotation);
annotation = getPhysicalAnnotation(Column.class);
addIfNotNull(annotationList, annotation);
annotation = getPhysicalAnnotation(Columns.class);
addIfNotNull(annotationList, annotation);
annotation = getPhysicalAnnotation(GeneratedValue.class);
addIfNotNull(annotationList, annotation);
annotation = getPhysicalAnnotation(Temporal.class);
addIfNotNull(annotationList, annotation);
annotation = getPhysicalAnnotation(TableGenerator.class);
addIfNotNull(annotationList, annotation);
annotation = getPhysicalAnnotation(SequenceGenerator.class);
addIfNotNull(annotationList, annotation);
annotation = getPhysicalAnnotation(AttributeOverride.class);
addIfNotNull(annotationList, annotation);
annotation = getPhysicalAnnotation(AttributeOverrides.class);
addIfNotNull(annotationList, annotation);
annotation = getPhysicalAnnotation(AssociationOverride.class);
addIfNotNull(annotationList, annotation);
annotation = getPhysicalAnnotation(AssociationOverrides.class);
addIfNotNull(annotationList, annotation);
}
}
}
Aggregations