Marco Belladelli (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=637b480...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiZGYyNmRhOTEx...
) / Improvement (
https://hibernate.atlassian.net/browse/HHH-16761?atlOrigin=eyJpIjoiZGYyNm...
) HHH-16761 (
https://hibernate.atlassian.net/browse/HHH-16761?atlOrigin=eyJpIjoiZGYyNm...
) Throw an appropriate error when an entity defines more @Id fields than its @IdClass (
https://hibernate.atlassian.net/browse/HHH-16761?atlOrigin=eyJpIjoiZGYyNm...
)
Issue Type: Improvement Affects Versions: 6.2.4 Assignee: Marco Belladelli (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=637b480...
) Created: 07/Jun/2023 02:10 AM Priority: Major Reporter: Marco Belladelli (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=637b480...
)
Currently we have a validation that checks that all fields of an @IdClass are included in
the corresponding entity class as @Id annotated properties.
We do not, however, check if there are more @Id annotated fields in the entity than what
we expect, and this causes unexpected behavior (i.e. the additional @Id field might
“override” the @IdClass and be set as simple-valued identifier for the entity class).
For example:
public static class PK {
private Long id;
private String username;
}
@Entity
@IdClass( PK.class )
public static class User {
@Id
private Long id;
@Id
private String username;
@Id
private Integer anotherId;
}
This should be considered a wrong mapping, and an appropriate error should be thrown.
(
https://hibernate.atlassian.net/browse/HHH-16761#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16761#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#100225- sha1:62413c2 )