6.6.x regression - loading a JPA entity a second time when it contains composite key references can cause IllegalArgumentException in reflection code

Description

This is a problem we have in our production code when upgrading to Hibernate 6.6.x. In our production code we have some retry logic around some queries if they fail due to parallel accesses. Such a retry loading of an entity fails.

I have constructed a simplified test case which can be found at https://github.com/SchlauFuchs/hibernate-6.6-regression-proof

The code is in kotlin and uses Spring Data JPA framework to access to the database. The Hibernate enhancer plugin is used, too.

Attachments

3
  • 09 Jan 2025, 09:23 PM
  • 09 Jan 2025, 08:45 PM
  • 09 Jan 2025, 08:45 PM

Activity

Show:

Kai Hackemesser January 9, 2025 at 9:36 PM

I was able to remove the DocumentReceiver entity from the problem.

Kai Hackemesser January 9, 2025 at 9:23 PM
Edited

 

image-20250109-212122.png

Improved the Diagram to make clear that Owner is not an Entity but an embeddable structure.
Entities:

  • Document

  • DocumentReceiver (Xref table)

  • CorporationUser (Xref table)

  • Person (extends abstract User)

  • Corporation (extends abstract User)

Kai Hackemesser January 9, 2025 at 9:11 PM

Hint: when removing the embedded Owner class and move the fields into the Document class, the problem collapses.

Kai Hackemesser January 9, 2025 at 9:01 PM
Edited

So you are telling me I should write an extensive substack essay on why to abandon Hibernate JPA in any essential project that has more than 3 tables involved? grinning squinting face

Look at the entity graph and tell me which one you think I should remove without collapsing the problem? Given that they are all essential in our productive code and it is your regression that stops us from upgrading?

Gavin King January 9, 2025 at 8:55 PM

I removed Lombok but again this is just syntactic sugar and does not contribute to the problem!

I understand that. But I need you to understand that we use the reproducer you submit as the basis for the test that goes into the Hibernate ORM test suite. And we don’t have (nor want) Lombok in our code.

Nor do we want a test with seven entities in it!

So look, what I’m hearing from you is that this issue is not very important to you, at least not important enough for you to do the work on your side, and so I can just close the issue. Is that correct?

Rejected

Details

Assignee

Reporter

Labels

Worked in

Affects versions

Priority

Created December 17, 2024 at 12:13 AM
Updated January 9, 2025 at 9:55 PM
Resolved January 9, 2025 at 9:28 PM