Marco Belladelli (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=637b480...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiYWFkYWFlYjll...
) / Improvement (
https://hibernate.atlassian.net/browse/HHH-16313?atlOrigin=eyJpIjoiYWFkYW...
) HHH-16313 (
https://hibernate.atlassian.net/browse/HHH-16313?atlOrigin=eyJpIjoiYWFkYW...
) Throw an appropriate error when a mappedBy property references the wrong entity type (
https://hibernate.atlassian.net/browse/HHH-16313?atlOrigin=eyJpIjoiYWFkYW...
)
Issue Type: Improvement Assignee: Marco Belladelli (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=637b480...
) Created: 15/Mar/2023 06:48 AM Priority: Major Reporter: Marco Belladelli (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=637b480...
)
We have seen multiple cases of users migrating from Hibernate 5 to 6 getting errors caused
by having an invalid mapping: entity collections annotated with a mappedBy which
references a property of a different type of the original entity. For example:
@Entity
public static class EntityA {
@Id
private Long id;
@OneToMany( mappedBy = "three" )
private List<EntityB> twos;
}
@Entity
public static class EntityB {
@Id
private Long id;
@ManyToOne
private EntityC three;
}
@Entity
public static class EntityC {
@Id
private Long id;
}
This type of mappings used to work in Hibernate 5 (with unexpected results), but in 6 it
causes errors.
We should check the mappedBy property type and give a give a more informative error
message.
(
https://hibernate.atlassian.net/browse/HHH-16313#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16313#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100217- sha1:fd7c927 )