Skip to content

Register Hibernate @GenericGenerator strategy implementations for reflective access #1743

@kabir

Description

@kabir

@Sanne (as discussed on Zulip):
I have an entity using org.hibernate.id.UUIDGenerator:

public class AuthenticationRequest {

    @Id
    @GeneratedValue(generator = "UUID")
    @GenericGenerator(
            name = "UUID",
            strategy = "org.hibernate.id.UUIDGenerator"
    )
    @Column(name = "id", updatable = false, nullable = false)
    private UUID id;

This works fine in Java but when running in native mode I get:

Caused by: org.hibernate.MappingException: Could not interpret id generator strategy [org.hibernate.id.UUIDGenerator]
    at org.hibernate.id.factory.internal.DefaultIdentifierGeneratorFactory.getIdentifierGeneratorClass(DefaultIdentifierGeneratorFactory.java:144)
    at org.hibernate.mapping.SimpleValue.isIdentityColumn(SimpleValue.java:378)
    at org.hibernate.tool.schema.internal.StandardTableExporter.getSqlCreateStrings(StandardTableExporter.java:60)
    at org.hibernate.tool.schema.internal.StandardTableExporter.getSqlCreateStrings(StandardTableExporter.java:30)
    at org.hibernate.tool.schema.internal.SchemaCreatorImpl.createFromMetadata(SchemaCreatorImpl.java:316)
    at org.hibernate.tool.schema.internal.SchemaCreatorImpl.performCreation(SchemaCreatorImpl.java:166)
    at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:135)
    at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:121)
    at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:155)

Kabir Khan: Is there some trick I need to perform, or is it a bug?
Kabir Khan: BTW I am planning on ripping out this entity so it isn't a huge deal
Sanne Grinovero: @kabir Khan ah! thanks that's a useful bugreport :) Yes we probably need to register those strategy implementations for reflective access, didn't think of that.
Kabir Khan: Cool

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions