hibernate/hibernate-orm · error · AnnotationException

Entity '${name}' is annotated both '@DynamicUpdate' and '@SQ

Error message

Entity '${name}' is annotated both '@DynamicUpdate' and '@SQLUpdate'

What it means

Error "Entity '${name}' is annotated both '@DynamicUpdate' and '@SQLUpdate'" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java:1390

	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" );
		}
		final String entityName = entity.name();
		if ( StringHelper.isQuoted( entityName ) ) {
			throw new AnnotationException(

View on GitHub (pinned to fad1729dce)

Solutions

  1. Keep only one of @DynamicUpdate or @SQLUpdate 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/915519d6491fc9c5. Report an issue: GitHub.