hibernate/hibernate-orm · error · MappingException

@GeneratedValue for %s (%s) specified SEQUENCE generation, b

Error message

@GeneratedValue for %s (%s) specified SEQUENCE generation, but referred to a @GenericGenerator

What it means

Error "@GeneratedValue for %s (%s) specified SEQUENCE generation, but referred to a @GenericGenerator" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/boot/model/internal/IdGeneratorResolverSecondPass.java:122

		final var globalRegistrations = buildingContext.getMetadataCollector().getGlobalRegistrations();
		final String generator = generatedValue.generator();

		final var globalTableMatch = globalRegistrations.getTableGeneratorRegistrations().get( generator );
		if ( globalTableMatch != null ) {
			throw new MappingException(
					String.format(
							Locale.ROOT,
							"@GeneratedValue for %s (%s) specified SEQUENCE generation, but referred to a @TableGenerator",
							entityMapping.getEntityName(),
							generator
					)
			);
		}

		final var globalGenericMatch = globalRegistrations.getGenericGeneratorRegistrations().get( generator );
		if ( globalGenericMatch != null ) {
			throw new MappingException(
					String.format(
							Locale.ROOT,
							"@GeneratedValue for %s (%s) specified SEQUENCE generation, but referred to a @GenericGenerator",
							entityMapping.getEntityName(),
							generator
					)
			);
		}
	}


	// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// TABLE

	@Override
	protected void handleUnnamedTableGenerator() {
		// todo (7.0) : null or entityMapping.getJpaEntityName() for "name from GeneratedValue"?

View on GitHub (pinned to fad1729dce)

Solutions

  1. Reference a @SequenceGenerator for SEQUENCE generation instead of a @GenericGenerator.

When it happens

Trigger: An identifier/value generator declaration is inconsistent with the referenced generator or the annotated element.

Common situations: @GeneratedValue pointing at a generator of the wrong kind (SEQUENCE vs TABLE), a missing named generator, too many generator annotations, or an unsupported generation strategy for @CollectionId.


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