Bug 428 : ManyToMany associations not persisted
Priority 
High
Reported Version 
 
Logged By 
James Roper
Status 
Fixed
Fixed Version 
3.x
Assigned To 
 
Product 
Ebean - core
Duplicate Of 
 
Created 
28/09/2012
Updated 
28/09/2012
Type 
Bug
 
Attachments 
No attachments

In DeployBeanPropertyLists.getMany(Mode), ManyToMany associations are correctly added to the list of associations to cascade on save, regardless of whether the association is configured to cascade or not, as indicated by the comment in that method.

However, when it comes to using this list:


if (saveMany.getMany().isManyToMany()) {
// save the beans that are in the manyToMany
if (saveMany.isCascade()) {
// Need explicit Cascade to save the beans on other side
saveAssocManyDetails(saveMany, false, saveMany.isUpdateNullProperties());
// for ManyToMany save the 'relationship' via inserts/deletes
// into/from the intersection table
saveAssocManyIntersection(saveMany, saveMany.isDeleteMissingChildren());
}
} else {
...

The association is only saved if cascade is configured. the saveAssocManyIntersection call should be outside of that if statement.

 
James Roper 28 Sep 09:39
Pull request

https://github.com/rbygrave/avaje-ebeanorm-server/pull/1

woResponse

Upload a file