geoffrey deremetz (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5ea439b...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiMDllMmQzNzI1...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16901?atlOrigin=eyJpIjoiMDllMm...
) HHH-16901 (
https://hibernate.atlassian.net/browse/HHH-16901?atlOrigin=eyJpIjoiMDllMm...
) Hibernate 6 : Embedded field not correctly instantiated (
https://hibernate.atlassian.net/browse/HHH-16901?atlOrigin=eyJpIjoiMDllMm...
)
Issue Type: Bug Assignee: Unassigned Attachments: hibernate_bug.zip Created: 05/Jul/2023
11:59 AM Environment: Spring boot 3.1.1
Hibernate 6.2.5.Final Priority: Major Reporter: geoffrey deremetz (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5ea439b...
)
Spring boot 3.1.1 - Hibernate 6.2.5.Final
Embedded field are not correctly instantiated when I use a composite key to load my
entity
@Entity
@Table(name = "trip")
public class Trip {
@Id
public Long id;
@Embedded
@AttributeOverrides({
@AttributeOverride(name = "date", column = @Column(name =
"date_position1")),
})
@AssociationOverride(name = "poi", joinColumns = @JoinColumn(name =
"poi1_id_fk"))
public Location position1 = new Location();
@Embedded
@AttributeOverrides({
@AttributeOverride(name = "date", column = @Column(name =
"date_position2")),
})
@AssociationOverride(name = "poi", joinColumns = @JoinColumn(name =
"poi2_id_fk"))
public Location position2 = new Location();
}
in certain scenarios (see my code attached), trip.position2 is null when it shouldn't
be ( poi2_id_fk is null but not date_position2 )
scenario 1 (working)
Trip trip = tripRepository.findById(1L).orElseThrow();
assertThat(trip.position1).isNotNull();
assertThat(trip.position2).isNotNull();
scenario 2 (not working)
Optional<Report> reportOptional = repository.findById(1L);
assertThat(reportOptional).isPresent();
Report report = reportOptional.get();
assertThat(report.reportTripList.get(0).compositeKey.trip.position1).isNotNull();
assertThat(report.reportTripList.get(0).compositeKey.trip.position2).isNotNull();
// ko
(
https://hibernate.atlassian.net/browse/HHH-16901#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16901#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#100229- sha1:634ba05 )