SCJP 1.4 / 5.0 - SCBCD 1.3 - SCWCD 1.4 - IBM 484
This exception is thrown when an operation would break session-scoped identity. This occurs if the user tries to associate two different instances of the same Java class with a particular identifier, in the scope of a single Session.
SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
Originally posted by Somkiat Puisungnoen:
class NonUniqueObjectException
SCJP 1.4 / 5.0 - SCBCD 1.3 - SCWCD 1.4 - IBM 484
Copy the state of the given object onto the persistent object with the same identifier. If there is no persistent instance currently associated with the session, it will be loaded. Return the persistent instance. If the given instance is unsaved or does not exist in the database, save it and return it as a newly persistent instance. Otherwise, the given instance does not become associated with the session.
Originally posted by pascal betz:
check Session.saveOrUpdateCopy()
Hibernate API saveOrUpdateCopy
Spring API
im not sure this is the way to go ?
cheers
pascal
SCJP 1.4 / 5.0 - SCBCD 1.3 - SCWCD 1.4 - IBM 484
Originally posted by pascal betz:
saveOrUpdateCopy()
isnt this what you are looking for ?
pascal
SCJP 1.4 / 5.0 - SCBCD 1.3 - SCWCD 1.4 - IBM 484
Originally posted by pascal betz:
is this what you want to do ?
1. start tx
2. load object A
3. close tx
4. change object A (-> Object B)
5. start tx
6. load object A
7. compare A to B
8. store() B
9. close tx
Originally posted by pascal betz:
at step 6 you have the object in your session thats why you can not store another object with the same id in step 8.
but if you either evict() A from the session before step 8 or use saveOrUpdateCopy() in step 8, then it should work.
Originally posted by pascal betz:
but perhaps i'm longing for the weekend and my brain stopped working some hours ago and i got you completely wrong :-)
cheers
pascal
SCJP 1.4 / 5.0 - SCBCD 1.3 - SCWCD 1.4 - IBM 484
Luthiano Vasconcelos, PMP
Error: Keyboard not attached. Press F1 to continue.
I have gone to look for myself. If I should return before I get back, keep me here with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|