...
So now the Problem is updating the Collection of B-Objects Lets say a1 has already 2 B-Objects within the collection (b1 and b2): Now I want to update the Collection and put the Objects (b3 and b4) into
it - b3 and b4 are already existing in the DB just belong to a2.
The situation: a1{b1,b2}, a2{b3,b4} ---> a1{b3,b4}, a2{}, (b1 and b2 have null
references to any A-Object)
Yeah, every Object I have has been loaded via PB-API.Do you lookup a1, a2 via PB-api too? If so, do you lock them before starting your modification?
My Applicationflow looks like this (web-application using Struts, running in Tomcat): 1. Action: using PB-API to get all A-Objects and put them into Session-Scope 2. JSP: Show all A-Objects and referenced Bs.. just to see which Bs are pointing to which a. 3. User Interaction: Edit a1 4. EditAction: using PB-API to get all possible B-Objects so that the User can define which B-Objects he wants. 5. JSP: Show a1 and a List of B-Objects where he can choose... Let's say he chose the b3 and b4 6. SaveAction: I get the Object a1 (toBeSaved), the b3 and b4 from the DB (PB-API) (could have got it from the session-scope bean as well ) 7. Now I begin the transaction and lock the toBeSaved-Object... 8. make the changes and commit..
that's all..
hmm, can you try to do a ((TransactionExt) tx).markDirty(a1); ((TransactionExt) tx).markDirty(a2); // if was modified too
before do the commit.
regards, Armin
regards,
Ralf
If I am not mistaken the steps OJB takes should look like this:
1. Delete the references of b1 (aid=null and refToA=null) and b2 which
are pointing to a1
2. Update the references of b3 and b4 so that they point to a1. 3. Update the Collection of a2 because b3 and b4 are not in the
collection of a2 anymore.
4 Update the Collection of a1: delete the references to b1 and b2 and
fill the collection with b3 and b4.
commit;
I tried several Collections (java.util.Vector, ManageableVector,
ManageableArrayList, DListImpl)
but nothing works. basically it for me it looks like this:
tx.begin() // Get the Collection of new Bs with
PersistenceBroker.getCollectionByQuery(B.class, crit) so I get this Collection: newColOfB{b3,b4}
// Get the Collection of a1: ManageableArrayList list = a1.getColOfB();
// now update the list: list.retainAll( newColOfB );
tx.commit();
But nothing has been updated in the DB..
What is it ?? Can somebody please point out how to solve this problem ?
I really lost my nerves. Do I really have to update all references by myselfe ??
Or am I just too stupid ? It works fine with m:n relationships.. just
setting the new collection..
Thanks for your help,
Ralf Geiger
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
