use of org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor in project hibernate-orm by hibernate.
the class JPAOverriddenAnnotationReader method getMapKeyClass.
private void getMapKeyClass(List<Annotation> annotationList, Element element, XMLContext.Default defaults) {
String nodeName = "map-key-class";
Element subelement = element != null ? element.element(nodeName) : null;
if (subelement != null) {
String mapKeyClassName = subelement.attributeValue("class");
AnnotationDescriptor ad = new AnnotationDescriptor(MapKeyClass.class);
if (StringHelper.isNotEmpty(mapKeyClassName)) {
Class clazz;
try {
clazz = classLoaderAccess.classForName(XMLContext.buildSafeClassName(mapKeyClassName, defaults));
} catch (ClassLoadingException e) {
throw new AnnotationException("Unable to find " + element.getPath() + " " + nodeName + ": " + mapKeyClassName, e);
}
ad.setValue("value", clazz);
}
annotationList.add(AnnotationFactory.create(ad));
}
}
use of org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor in project hibernate-orm by hibernate.
the class JPAOverriddenAnnotationReader method buildGeneratedValue.
private GeneratedValue buildGeneratedValue(Element element) {
Element subElement = element != null ? element.element("generated-value") : null;
if (subElement != null) {
AnnotationDescriptor ad = new AnnotationDescriptor(GeneratedValue.class);
String strategy = subElement.attributeValue("strategy");
if ("TABLE".equalsIgnoreCase(strategy)) {
ad.setValue("strategy", GenerationType.TABLE);
} else if ("SEQUENCE".equalsIgnoreCase(strategy)) {
ad.setValue("strategy", GenerationType.SEQUENCE);
} else if ("IDENTITY".equalsIgnoreCase(strategy)) {
ad.setValue("strategy", GenerationType.IDENTITY);
} else if ("AUTO".equalsIgnoreCase(strategy)) {
ad.setValue("strategy", GenerationType.AUTO);
} else if (StringHelper.isNotEmpty(strategy)) {
throw new AnnotationException("Unknown GenerationType: " + strategy + ". " + SCHEMA_VALIDATION);
}
copyStringAttribute(ad, subElement, "generator", false);
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 getDiscriminatorValue.
private DiscriminatorValue getDiscriminatorValue(Element tree, XMLContext.Default defaults) {
Element element = tree != null ? tree.element("discriminator-value") : null;
if (element != null) {
AnnotationDescriptor ad = new AnnotationDescriptor(DiscriminatorValue.class);
copyStringElement(element, ad, "value");
return AnnotationFactory.create(ad);
} else if (defaults.canUseJavaAnnotations()) {
return getPhysicalAnnotation(DiscriminatorValue.class);
} else {
return null;
}
}
use of org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor in project hibernate-orm by hibernate.
the class JPAOverriddenAnnotationReader method getEmbedded.
private void getEmbedded(List<Annotation> annotationList, XMLContext.Default defaults) {
for (Element element : elementsForProperty) {
if ("embedded".equals(element.getName())) {
AnnotationDescriptor ad = new AnnotationDescriptor(Embedded.class);
annotationList.add(AnnotationFactory.create(ad));
Annotation annotation = getAttributeOverrides(element, defaults, false);
addIfNotNull(annotationList, annotation);
annotation = getAssociationOverrides(element, defaults, false);
addIfNotNull(annotationList, annotation);
getAccessType(annotationList, element);
}
}
if (elementsForProperty.size() == 0 && defaults.canUseJavaAnnotations()) {
Annotation annotation = getPhysicalAnnotation(Embedded.class);
if (annotation != null) {
annotationList.add(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);
}
}
}
use of org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor in project hibernate-orm by hibernate.
the class JPAOverriddenAnnotationReader method getAccessType.
private Access getAccessType(Element tree, XMLContext.Default defaults) {
String access = tree == null ? null : tree.attributeValue("access");
if (access != null) {
AnnotationDescriptor ad = new AnnotationDescriptor(Access.class);
AccessType type;
try {
type = AccessType.valueOf(access);
} catch (IllegalArgumentException e) {
throw new AnnotationException(access + " is not a valid access type. Check you xml confguration.");
}
ad.setValue("value", type);
return AnnotationFactory.create(ad);
} else if (defaults.canUseJavaAnnotations() && isPhysicalAnnotationPresent(Access.class)) {
return getPhysicalAnnotation(Access.class);
} else if (defaults.getAccess() != null) {
AnnotationDescriptor ad = new AnnotationDescriptor(Access.class);
ad.setValue("value", defaults.getAccess());
return AnnotationFactory.create(ad);
} else {
return null;
}
}
Aggregations