-
1. Re: ejb3 - setList(Set<MyObjs> list) - fails to persist.
wolfgangknauf Mar 12, 2007 1:28 PM (in response to hanasakijiji)Hi !
I will try to help:
Q1:
If you need only one cascade type value you use the single item notation:cascade=CascadeType.ALL
You can OR the casace type values:
The following sample will cascade any operation beside a delete (and here you will need the array notation):cascade={CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH}
Q2: I think you don't need to initialize the relationship field with a value. Set it to null, the container will do the rest.
When you create relationship items you should update both sides of the relationship.
Something like:myObject.getOwnedItems.add(unsavedNewOwnedItem); unsavedNewOwnedItem.setObject (myObject);
Hope this helps
Wolfgang -
2. Re: ejb3 - setList(Set<MyObjs> list) - fails to persist.
hanasakijiji Mar 12, 2007 9:44 PM (in response to hanasakijiji)Unfortunately, the suggestion did not change the behavior. I have also double checked the "equals" method to be sure its working, and it is.
Other thoughts? The same behavior is reproducable with:
jboss 4.0.4, 4.0.5
windows, linux
jdk 1.5.x and 1.6.x
postgresql and mysql -
3. Re: ejb3 - setList(Set<MyObjs> list) - fails to persist.
wolfgangknauf Mar 13, 2007 9:06 AM (in response to hanasakijiji)Please post the relevant code of your beans.
Wolfgang -
4. Re: ejb3 - setList(Set<MyObjs> list) - fails to persist.
hanasakijiji Mar 13, 2007 10:51 PM (in response to hanasakijiji)Hi Wlfgang and all...
I will try to get the code posted soon. In the meantime... I have narrowed things down. What do you make of this?
Class1 actually has two getters as above.
Set<OwnedItem1> getOwned1();
Set<OwnedItem2> getOwned2();
Each has has its own jointable and all are connected by the Integer Primary Keys of their respective tables
Class1 - jointable1toOwned1 - Owned1
Class1 - jointable1toOwned2 - Owned2
It turns out that getOwned2 returns a Set with a maximum set.size of the number of items in getOwned1. Amost like an inner join where an outter join is required.