Christian Beikov (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiYTAzOWJiZjI1...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16021?atlOrigin=eyJpIjoiYTAzOW...
) HHH-16021 (
https://hibernate.atlassian.net/browse/HHH-16021?atlOrigin=eyJpIjoiYTAzOW...
) OneToOne association with non-PK foreign key target (
https://hibernate.atlassian.net/browse/HHH-16021?atlOrigin=eyJpIjoiYTAzOW...
)
Issue Type: Bug Assignee: Unassigned Created: 11/Jan/2023 02:27 AM Priority: Major
Reporter: Christian Beikov (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
While working on a different issue, we found out that the mapping model assumes that the
ParkingSpot#assignedTo association refers to the primary key of Employee , even though the
@JoinColumn explicitly specifies the referencedColumnName to be something other than the
primary key.
This is just a synthetic model that we thought about, and I think the workaround to use
mappedBy should be good enough, but I wanted to capture it anyway.
@Entity(name = "Employee")
public static class Employee {
@Id
int id;
String name;
@Embedded
LocationDetails location;
}
@Embeddable
public static class LocationDetails {
int officeNumber;
@OneToOne
ParkingSpot parkingSpot;
}
@Entity(name = "ParkingSpot")
public static class ParkingSpot {
@Id
//int id;
Integer id;
String garage;
@OneToOne
// Case 1, with maps id
@MapsId
@JoinColumn(name = "id", referencedColumnName = "parking_spot_id")
// Case 2, with explicit config of what @MapsId does behind the scenes
//@JoinColumn(name = "id", referencedColumnName = "parking_spot_id",
insertable = false, updatable = false)
//@NotFound(action = NotFoundAction.IGNORE)
Employee assignedTo;
}
(
https://hibernate.atlassian.net/browse/HHH-16021#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16021#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#100213- sha1:b01baad )