Davide D'Alto (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *updated* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiYjk5ZWM3NTc1...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16297?atlOrigin=eyJpIjoiYjk5ZW...
) HHH-16297 (
https://hibernate.atlassian.net/browse/HHH-16297?atlOrigin=eyJpIjoiYjk5ZW...
) Removing an element from a collection of elements removes the whole collection (
https://hibernate.atlassian.net/browse/HHH-16297?atlOrigin=eyJpIjoiYjk5ZW...
)
Change By: Davide D'Alto (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
Given the following mapping:
{code:java} @ElementCollection(fetch = FetchType.EAGER)
private Set<String> phones;{code}
Removing an element when the entity is managed, will remove the whole collection.
Example:
{noformat} @Test
public void removeElementAndAddNewOne(SessionFactoryScope scope) {
scope.inTransaction( session -> {
Person foundPerson = session.find( Person.class, thePerson.getId() );
Assertions.assertThat( foundPerson ).isNotNull();
foundPerson.getPhones().remove( "111-111-1111" );
foundPerson.getPhones().add( "000" );
assertThat( foundPerson.getPhones() )
.containsExactlyInAnyOrder( "999-999-9999", "123-456-7890",
"000" );
} );
scope.inTransaction( session -> {
Person person = session.find( Person.class, thePerson.getId() );
// Fails because it only contains "000"
assertThat( person.getPhones() )
.containsExactlyInAnyOrder( "999-999-9999", "123-456-7890",
"000" );
} );
}{noformat}
(
https://hibernate.atlassian.net/browse/HHH-16297#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16297#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:7167dc8 )