Circular entities throwing UnknownTableReferenceException in 6.x

Description

When having dependencies like:
A → B → C → A

An error (UnknownTableReferenceException) is thrown after upgrading to hibernate 6.1.6.Final. When using hibernate 5.x, this causes no issue. I’ve reproduced it using a demo project;

full stacktrace:

Activity

Show:

Marco Belladelli March 20, 2023 at 4:40 PM

Hibernate 6.2 will introduce a check for this type of problem and an appropriate error message, as per .

Closing the issue.

Wilko January 30, 2023 at 8:20 AM

Hi Andrea,

Thanks for your response, I am aware this is an weird way of the relationship between the entities. However, I did not expect this to no longer work with hibernate 6, while it was working with hibernate 5.

 

Kind regards,

Wilko

Andrea Boriero January 27, 2023 at 2:09 PM

Hi ,

the issue is caused by a wrong use of mappedBy ,

for a B ↔︎ C relationship you are specifying as a bidirectional target a property of type A while it should be of type B . I think you should just remove the mappedBy from the @OneToMany .

Rejected

Details

Assignee

Reporter

Affects versions

Priority

Created January 26, 2023 at 1:45 PM
Updated March 20, 2023 at 4:40 PM
Resolved March 20, 2023 at 4:40 PM