hibernate/hibernate-orm · error · MappingException

Style [%s] should not be specified with custom UUID value ge

Error message

Style [%s] should not be specified with custom UUID value generator: %s.%s

What it means

Error "Style [%s] should not be specified with custom UUID value generator: %s.%s" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/id/uuid/UuidGenerator.java:123

	@Internal
	public ValueTransformer getValueTransformer() {
		return valueTransformer;
	}

	private static UuidValueGenerator determineValueGenerator(
			org.hibernate.annotations.UuidGenerator config,
			String memberDeclaringClassName,
			String memberName) {
		if ( config == null ) {
			return StandardRandomStrategy.INSTANCE;
		}
		else {
			// there is an annotation
			final var style = config.style();
			if ( config.algorithm() != UuidValueGenerator.class ) {
				// the annotation specified a custom algorithm
				if ( style != AUTO ) {
					throw new MappingException(
							String.format(
									Locale.ROOT,
									"Style [%s] should not be specified with custom UUID value generator: %s.%s",
									style.name(),
									memberDeclaringClassName,
									memberName
							)
					);
				}
				return instantiateCustomGenerator( config.algorithm() );
			}
			return switch ( style ) {
				case TIME -> new CustomVersionOneStrategy();
				case VERSION_6 -> UuidVersion6Strategy.INSTANCE;
				case VERSION_7 -> UuidVersion7Strategy.INSTANCE;
				default -> StandardRandomStrategy.INSTANCE;
			};
		}

View on GitHub (pinned to fad1729dce)

Solutions

  1. Remove the 'style' parameter from the UUID generator configuration when a custom value generator class is used.

When it happens

Trigger: Thrown when a custom UUID value generator is combined with an incompatible style setting.

Common situations: Typical situations: specifying a style together with a custom UUID generator; conflicting @UuidGenerator attributes.


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