hibernate/hibernate-orm · error · MappingException

No generator type specified by @GenericGenerator

Error message

No generator type specified by @GenericGenerator

What it means

GenericGeneratorGeneration could not determine a generator class: the @GenericGenerator annotation has neither a type() class nor a resolvable strategy() name applicable to a SimpleValue. MappingException on the incomplete annotation; the input at fault is the annotation configuration.

Solutions

  1. Specify the 'type' (strategy) of the @GenericGenerator so Hibernate knows which generator class to use.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown when a @GenericGenerator mapping is incomplete or references a generator that cannot be resolved.

Common situations: Typical situations: missing type/strategy attribute on @GenericGenerator; misspelled generator strategy name.


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

Appendix: source

Thrown at hibernate-core/src/main/java/org/hibernate/id/GenericGeneratorGeneration.java:83

		if ( delegate.requiresIdentityColumn() ) {
			setColumnToIdentity( context.getValue() );
		}
	}

	private static Class<? extends Generator> generatorType(
			GenericGenerator annotation,
			GeneratorCreationContext context) {
		final var type = annotation.type();
		if ( type != null ) {
			return type;
		}
		else if ( annotation instanceof GenericGeneratorAnnotation generatorAnnotation
				&& generatorAnnotation.strategy() != null
				&& context.getValue() instanceof SimpleValue idValue ) {
			return generatorClass( generatorAnnotation.strategy(), idValue );
		}
		else {
			throw new MappingException( "No generator type specified by @GenericGenerator" );
		}
	}

	private void configure(GenericGenerator annotation, GeneratorCreationContext context) {
		if ( delegate instanceof Configurable configurable ) {
			configurable.configure( context, collectParameters( annotation, context ) );
		}
		if ( delegate instanceof ExportableProducer exportableProducer ) {
			exportableProducer.registerExportables( context.getDatabase() );
		}
		if ( delegate instanceof Configurable configurable ) {
			configurable.initialize( context.getSqlStringGenerationContext() );
		}
	}

	private static Properties collectParameters(
			GenericGenerator annotation,
			GeneratorCreationContext context) {

View on GitHub (pinned to fad1729dce)