org.hibernate.annotations.ValueGenerationType Java Examples
The following examples show how to use
org.hibernate.annotations.ValueGenerationType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PropertyBinder.java From lams with GNU General Public License v2.0 | 5 votes |
/** * In case the given annotation is a value generator annotation, the corresponding value generation strategy to be * applied to the given property is returned, {@code null} otherwise. */ private <A extends Annotation> AnnotationValueGeneration<A> getValueGenerationFromAnnotation( XProperty property, A annotation) { ValueGenerationType generatorAnnotation = annotation.annotationType() .getAnnotation( ValueGenerationType.class ); if ( generatorAnnotation == null ) { return null; } Class<? extends AnnotationValueGeneration<?>> generationType = generatorAnnotation.generatedBy(); AnnotationValueGeneration<A> valueGeneration = instantiateAndInitializeValueGeneration( annotation, generationType, property ); if ( annotation.annotationType() == Generated.class && property.isAnnotationPresent( javax.persistence.Version.class ) && valueGeneration.getGenerationTiming() == GenerationTiming.INSERT ) { throw new AnnotationException( "@Generated(INSERT) on a @Version property not allowed, use ALWAYS (or NEVER): " + StringHelper.qualify( holder.getPath(), name ) ); } return valueGeneration; }