Skip to content

Current Hibernate needs reflective access to equals(…)/hashCode() for complex identifier types #33664

@odrotbohm

Description

@odrotbohm

Given a simple JPA arrangement like this:

@Embeddable
record MyId(UUID id) {}

@Entity
class MyEntity {
  @EmbeddedId MyId id;
}

a GraalVM execution of a current Spring Boot 3.3.4 application will log the following output:

… : HHH000038: Composite-id class does not override equals(): ….MyId
… : HHH000039: Composite-id class does not override hashCode(): ….MyId

That is because Hibernate verifies the identifier types for the presence of equals(…)/hashCode(). Apparently, our JPA entity processing does not yet expose these modules. I had originally reported the issue to Hibernate, assuming it was a bug in it. I ended up suggesting that they should avoid the reflective lookups for records in the first place, as the methods are present by definition. Depending on the outcome of that discussion, I wonder if it's worth exposing the additional methods on our side.

The symptoms can be observed in the Spring RESTBucks sample project by executing the following steps:

$ git clone https://github.com/odrotbohm/spring-restbucks
$ cd spring-restbucks/server
$ ./mvnw -Pbuildpacks-native
$ docker run -p 8080:8080 docker.io/library/restbucks:1.0.0-SNAPSHOT

Metadata

Metadata

Assignees

Labels

for: external-projectNeeds a fix in external projectin: dataIssues in data modules (jdbc, orm, oxm, tx)status: declinedA suggestion or change that we don't feel we should currently applytheme: aotAn issue related to Ahead-of-time processing

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions