I want the following functionality
1. I need to 'load' an object (let's say a person object with name Jack) in the session an object for validation
2. Need to 'saveOrUpdate' it later
It throws NonUniqueObjectException.
To avoid this I tried the following
1. first use currentsession.contains(thisinstance). If false, use saveOrUpdate. true, do nothing
- it didnt work. contains returns False in this case but saveOrUpdate fails subsequently.
2. used merge. Didnt work too. merger does not associate the instance to the session
Looks like, contains will return true only when the same instance is stored in the session and saveOrUpdate will throw exception even when different instances use same 'identifier' to be stored in the session.
what is the solution?
|