-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Open
Description
It's generated code:
@Override
public void updatedEventToIssueSummary(IssueSummary out, IssueUpdatedEvent event) {
if ( event == null ) {
return;
}
if ( out.getChecklist() != null ) {
Collection<Checklist> collection = checklistDtoCollectionToChecklistCollection( event.getChecklist() );
if ( collection != null ) {
out.getChecklist().clear();
out.getChecklist().addAll( collection );
}
else {
out.setChecklist( null );
}
}
else {
Collection<Checklist> collection = checklistDtoCollectionToChecklistCollection( event.getChecklist() );
if ( collection != null ) {
out.setChecklist( collection );
}
}
...
}@Entity
public class IssueSummary {
...
@OneToMany(
cascade = CascadeType.ALL,
orphanRemoval = true,
fetch = FetchType.EAGER
)
Collection<Checklist> checklist;
}Flow
if ( out.getChecklist() != null ) {
if ( collection != null ) { ... }
else {
out.setChecklist( null );
}cause exception:
Hibernate - A collection with cascade=”all-delete-orphan” was no longer referenced by the owning entity instance
Problem solved by replacing out.setChecklist( null ); with out.getChecklist().clear();
Can it be done with @mapping annotation with nullValuePropertyMappingStrategy = CLEAR?
davidjlynn, mkczyk and drahkrub