hibernate/hibernate-orm · error · IllegalArgumentException

Attempted to overwrite registration [%s] for type definition

Error message

Attempted to overwrite registration [%s] for type definition.

What it means

Error "Attempted to overwrite registration [%s] for type definition." thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/boot/internal/TypeDefinitionRegistryStandardImpl.java:103

		}

		return this;
	}

	private void register(String name, TypeDefinition typeDefinition, DuplicationStrategy duplicationStrategy) {
		if ( duplicationStrategy == DuplicationStrategy.KEEP ) {
			if ( !typeDefinitionMap.containsKey( name ) ) {
				typeDefinitionMap.put( name, typeDefinition );
			}
		}
		else {
			final var existing = typeDefinitionMap.put( name, typeDefinition );
			if ( existing != null && existing != typeDefinition ) {
				if ( duplicationStrategy == DuplicationStrategy.OVERWRITE ) {
					BOOT_LOGGER.overwroteExistingRegistrationForTypeDefinition( name );
				}
				else {
					throw new IllegalArgumentException(
							String.format(
									Locale.ROOT,
									"Attempted to overwrite registration [%s] for type definition.",
									name
							)
					);
				}
			}
		}
	}

	@Override
	public Map<String, TypeDefinition> copyRegistrationMap() {
		return new HashMap<>( typeDefinitionMap );
	}
}

View on GitHub (pinned to fad1729dce)

Solutions

  1. Avoid registering the same type definition name twice; check for duplicate @TypeDef/@JavaTypeRegistration annotations or repeated programmatic registration.
  2. If override is intended, use the registry method that explicitly allows overwriting, or unregister the old one first.
  3. Check that the same configuration is not applied twice (e.g. both hbm.xml and annotations).

When it happens

Trigger: A runtime precondition of the Hibernate API is violated.

Common situations: Occurs when application code or configuration does not satisfy the documented contract of the API being called.


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/ce6ebd6e3c6e347e. Report an issue: GitHub.