detect use of custom SQL with @DynamicInsert/@DynamicUpdate

and produce nice error
This commit is contained in:
Gavin King 2024-03-07 13:44:54 +01:00
parent 2a2fea5d7b
commit 39cd03d1a5
1 changed files with 8 additions and 0 deletions

View File

@ -1225,6 +1225,14 @@ public class EntityBinder {
persistentClass.setDynamicInsert( dynamicInsertAnn != null && dynamicInsertAnn.value() );
final DynamicUpdate dynamicUpdateAnn = annotatedClass.getAnnotation( DynamicUpdate.class );
persistentClass.setDynamicUpdate( dynamicUpdateAnn != null && dynamicUpdateAnn.value() );
if ( persistentClass.useDynamicInsert() && annotatedClass.isAnnotationPresent( SQLInsert.class ) ) {
throw new AnnotationException( "Entity '" + name + "' is annotated both '@DynamicInsert' and '@SQLInsert'" );
}
if ( persistentClass.useDynamicUpdate() && annotatedClass.isAnnotationPresent( SQLUpdate.class ) ) {
throw new AnnotationException( "Entity '" + name + "' is annotated both '@DynamicUpdate' and '@SQLUpdate'" );
}
final SelectBeforeUpdate selectBeforeUpdateAnn = annotatedClass.getAnnotation( SelectBeforeUpdate.class );
persistentClass.setSelectBeforeUpdate( selectBeforeUpdateAnn != null && selectBeforeUpdateAnn.value() );
}