use of org.hibernate.boot.jaxb.mapping.spi.JaxbEntityListeners in project hibernate-orm by hibernate.
the class JPAXMLOverriddenAnnotationReader method getEntityListeners.
private EntityListeners getEntityListeners(ManagedType root, XMLContext.Default defaults) {
JaxbEntityListeners element = root instanceof EntityOrMappedSuperclass ? ((EntityOrMappedSuperclass) root).getEntityListeners() : null;
if (element != null) {
List<Class> entityListenerClasses = new ArrayList<>();
for (JaxbEntityListener subelement : element.getEntityListener()) {
String className = subelement.getClazz();
try {
entityListenerClasses.add(classLoaderAccess.classForName(XMLContext.buildSafeClassName(className, defaults)));
} catch (ClassLoadingException e) {
throw new AnnotationException("Unable to find class: " + className, e);
}
}
AnnotationDescriptor ad = new AnnotationDescriptor(EntityListeners.class);
ad.setValue("value", entityListenerClasses.toArray(new Class[entityListenerClasses.size()]));
return AnnotationFactory.create(ad);
} else if (defaults.canUseJavaAnnotations()) {
return getPhysicalAnnotation(EntityListeners.class);
} else {
return null;
}
}
Aggregations