Search in sources :

Example 1 with AnnotationValueGeneration

use of org.hibernate.tuple.AnnotationValueGeneration in project hibernate-orm by hibernate.

the class PropertyBinder method instantiateAndInitializeValueGeneration.

/**
	 * Instantiates the given generator annotation type, initializing it with the given instance of the corresponding
	 * generator annotation and the property's type.
	 */
private <A extends Annotation> AnnotationValueGeneration<A> instantiateAndInitializeValueGeneration(A annotation, Class<? extends AnnotationValueGeneration<?>> generationType, XProperty property) {
    try {
        // This will cause a CCE in case the generation type doesn't match the annotation type; As this would be a
        // programming error of the generation type developer and thus should show up during testing, we don't
        // check this explicitly; If required, this could be done e.g. using ClassMate
        @SuppressWarnings("unchecked") AnnotationValueGeneration<A> valueGeneration = (AnnotationValueGeneration<A>) generationType.newInstance();
        valueGeneration.initialize(annotation, buildingContext.getBuildingOptions().getReflectionManager().toClass(property.getType()));
        return valueGeneration;
    } catch (HibernateException e) {
        throw e;
    } catch (Exception e) {
        throw new AnnotationException("Exception occurred during processing of generator annotation:" + StringHelper.qualify(holder.getPath(), name), e);
    }
}
Also used : HibernateException(org.hibernate.HibernateException) AnnotationException(org.hibernate.AnnotationException) AnnotationValueGeneration(org.hibernate.tuple.AnnotationValueGeneration) AnnotationException(org.hibernate.AnnotationException) HibernateException(org.hibernate.HibernateException)

Aggregations

AnnotationException (org.hibernate.AnnotationException)1 HibernateException (org.hibernate.HibernateException)1 AnnotationValueGeneration (org.hibernate.tuple.AnnotationValueGeneration)1