Deprecation of @GenericGenerator in Hibernate 6.5 and @EmbeddedId

We are using @GenericGenerator, that has been deprecated in favor of @IdGeneratorType in Hibernate 6.5 on an @EmbeddedId field:

@EmbeddedId
  @GeneratedValue(generator = "foobar")
  @GenericGenerator(
      name = "foobar",
      type = com.foobar.CustomTableBasedGenerator.class,
      parameters = @Parameter(name = "max_lo", value = "100"))
  private OIDIdentity identity;

But using an @IdGeneratorType-based on this @EmbeddedId field doesn’t work (in Hibernate 6.4.8.Final).
Our generator is a non-standard table-based generator that generates the PK of the Embeddable class.

Is there an alternative for replacing @GenericGenerator on @EmbeddedId fields?

Why don’t you place the generator annotation on the field in the OIDIdentity embeddable?

1 Like

This doesn’t work either.

Out custom annotation is also annotated with @ValueGenerationType:

@IdGeneratorType(SchemaHiLoGenerator.class)
@ValueGenerationType(generatedBy = SchemaHiLoGenerator.class)
@Retention(RUNTIME)
@Target({METHOD, FIELD})
public @interface SchemaHiLoIdGenerator {
  Parameter[] parameters() default {};
}

The initialize-Method of the generator class never gets called. No matter if the annotation is placed on the EmbeddedId-field of the entity class or on the corresponding field of the Embeddable class.

Besides, our generator needs the name of the table of the entity class.How can the table name be provided to the generator if the annotation is on the field of the reusable Embeddable class?

Please try to create a reproducer with our test case template and if you are able to reproduce the issue, create a bug ticket in our issue tracker and attach that reproducer.

Hi @beikov,
I’ve created bug ticket HHH-18276.