Bug 155 : Change Request - persist of ManyToMany for new collections
Priority 
High
Reported Version 
 
Logged By 
Rob
Status 
Fixed
Fixed Version 
2.2.0
Assigned To 
 
Product 
Ebean - core
Duplicate Of 
 
Created 
16/09/2009
Updated 
16/09/2009
Type 
Bug
 
Attachments 
No attachments

I got the following warning:
Sep 15, 2009 5:52:48 PM com.avaje.ebean.server.persist.DefaultPersister saveAssocManyIntersection
WARNING: Save cascade on ManyToMany [purposes]. The collection [class java.util.HashSet]was not a BeanCollection. The additions and removals can not be determined and *NO* inserts or deletes to the intersection table occured.

I understand the problem - the owning instance is new so the set is of course a HashSet and not a BeanCollection.
So what is the solution to this problem?
1) I need to save the owning object first and load it again so as I now have a BeanCollection
2) Cascading could probably assume that it should insert all the objects in the set if the owning object is new?

Perhaps there is a simple elegant solution?

 
Rob 16 Sep 09:22
Aka, the original thinking/design could be considered too conservative

Hmmm,

Yes, 2) is probably an option...

The other option is to just insert if it's not a BeanCollection and not bother checking the parent.

If it is not a BeanCollection then it's parent is new (not from query) or the application code set it... so either way it is probably reasonable to consider the beans it contains as inserts.

Aka, the original thinking/design could be considered too conservative.

Rob 18 Sep 08:45
Fixed in HEAD

This change has been made in HEAD.

So if the parent bean is new or the collection is 'vanilla' then all the entries are considered additions and insert into the intersection table.

woResponse

Upload a file