SIau_Tie wrote:
I am not clearly with your problem.
Can you use session.saveOrUpdate(object) ?
It is a little more complex than I described above.
The thing is, I have to access the lazy-loading set without saving any changes that might have been done to the object since it was loaded to the database.
(The Object is opened in the application in an edit form, which has a save button - until that button is pressed the object can not be written to the db, because the user could still just close the form without saving)
Now while the object is displayed in this form, the user may choose to open a tool on a sidebar of the application - this tool now has to access the lazy-set.
This tool now would like to know if the object is detached, transient or persistet to choose how to access the collection correctly.
Since I could not get that state what I do now is:
I check if the object id is not null (tells difference between transient & detached/persistet ) - if it is not null (=not transient) I load the set manually using the id, the class and a hql query like this "select mySet from class where id = id" and then attach the loaded set to the object. (object.setMySet(justLoadedFromDBSet) )- then i can access and modify the set and not care if the object ist attached to a session or not.
If the user chooses to press the save button the object is then saved with saveOrUpdate and the set is mapped with cascade="all" and all works out.
This is the solution for me.
So I think this closes this thread. - sorry for not beeing clear enough in the first post, I oversimplyfied the problem too far I guess.