wafa (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5ee6ae0...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiYTMwZmZjYmJl...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-14072?atlOrigin=eyJpIjoiYTMwZm...
) HHH-14072 (
https://hibernate.atlassian.net/browse/HHH-14072?atlOrigin=eyJpIjoiYTMwZm...
) PersistenceException for "More than one row with the given identifier was
found" Not raised when expected (
https://hibernate.atlassian.net/browse/HHH-14072?atlOrigin=eyJpIjoiYTMwZm...
)
Issue Type: Bug Affects Versions: 5.4.0, 5.3.15 Assignee: Unassigned Components:
hibernate-core Created: 14/Jun/2020 18:28 PM Labels: core hibernate Priority: Major
Reporter: wafa (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5ee6ae0...
)
For a OneToOne relationship, if the table associated with the owning side entity has 2
records related to the non-owning side entity, this should raise a PersistenceException,
claiming that "More than one row with the given identifier was found", e.g.:
public class EntityA {
@Id
@GeneratedValue
private Long id;
@OneToOne(mappedBy = "entityA" )
private EntityB entityB;
//...
}
public class EntityB {
@Id
@GeneratedValue
private Long id;
@OneToOne
@JoinColumn(name = "ENTITY_A_ID" , referencedColumnName = "ID" )
private EntityA entityA;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "entityB" , fetch =
FetchType.EAGER)
private List<EntityC> entityCS;
//...
}
If EntityB has an association of type ToMany with eager fetching, this will bypass the
duplicated foreign key references check for the OneToOne association with entity A, and
the Exception will not be thrown
From The AbstractEntityOwner load method code, the exception will not
be thrown if the Entity is a collection owner
if ( this.getCollectionOwners() != null ) {
return list.get(0);
} else {
throw new HibernateException( "More than one row with the given identifier
was found: " + id + ", for class: " + this.persister.getEntityName());
}
//...
There is no check if different records from owning side entity references the same key of
the non-owning side entity
(
https://hibernate.atlassian.net/browse/HHH-14072#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-14072#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#100128- sha1:14a4bff )