hibernate/hibernate-orm · error · AnnotationException
Entity '<name>' is annotated both '@DynamicInsert' and '@SQL
Error message
Entity '<name>' is annotated both '@DynamicInsert' and '@SQLInsert'
What it means
Error "Entity '<name>' is annotated both '@DynamicInsert' and '@SQLInsert'" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java:1387
*
* @return {@code true} if a property by that given name does already exist in the super hierarchy.
*/
public boolean isPropertyDefinedInSuperHierarchy(String name) {
// Yes, yes... persistentClass can be null because EntityBinder
// can be used to bind Components (naturally!)
return persistentClass != null
&& persistentClass.isPropertyDefinedInSuperHierarchy( name );
}
private void bindRowManagement() {
final var modelsContext = modelsContext();
final var dynamicInsert = annotatedClass.hasAnnotationUsage( DynamicInsert.class, modelsContext );
final var dynamicUpdate = annotatedClass.hasAnnotationUsage( DynamicUpdate.class, modelsContext );
persistentClass.setDynamicInsert( dynamicInsert );
persistentClass.setDynamicUpdate( dynamicUpdate );
if ( dynamicInsert && annotatedClass.hasAnnotationUsage( SQLInsert.class, modelsContext ) ) {
throw new AnnotationException( "Entity '" + name + "' is annotated both '@DynamicInsert' and '@SQLInsert'" );
}
if ( dynamicUpdate && annotatedClass.hasAnnotationUsage( SQLUpdate.class, modelsContext ) ) {
throw new AnnotationException( "Entity '" + name + "' is annotated both '@DynamicUpdate' and '@SQLUpdate'" );
}
}
private void bindOptimisticLocking() {
final var optimisticLocking = annotatedClass.getAnnotationUsage( OptimisticLocking.class, modelsContext() );
persistentClass.setOptimisticLockStyle( fromLockType( optimisticLocking == null
? OptimisticLockType.VERSION
: optimisticLocking.type() ) );
}
private void bindEntityAnnotation() {
final var entity = annotatedClass.getAnnotationUsage( Entity.class, modelsContext() );
if ( entity == null ) {
throw new AssertionFailure( "@Entity should never be missing" );
}View on GitHub (pinned to fad1729dce)
Solutions
- Keep only one of @DynamicInsert or @SQLInsert on the entity.
When it happens
Trigger: Two mutually exclusive annotations are placed on the same property or class.
Common situations: Combining annotations Hibernate treats as alternatives (e.g. @DynamicInsert with @SQLInsert, @MapKey with @MapKeyColumn), often after copy-pasting mappings or upgrading versions.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/5881a47ae76aa4f7.
Report an issue: GitHub.