Problems with Session and transaction handling?
Yes I do.
Read this:
http://hibernate.org/42.html
Done. I understand the problem, but I don't know the solution. Therefore I hope somebody here can help me.
I am working on a Swing application, with simple JDBC transaction handling. Therefore I have my objects lying around for a long time, which causes problemes:
1. A user creates a new Object (a) and saves it. This obviously causes a commit and therefor the session and transaction ends. But the user has it still open in the editor. When he now selects all objects of the class from the database. The same object (in the sense of same PK-ID) does exist twice in the VM :(
I thought I could fix it by configuring a 2nd Level Cache. But it doesn't work. So question 1: Does a cached object acctually ensure object identity or does it only prevent repeatativ loads from the database?
2. If the user opens a object, then causes a commit in a different dialog. If I now try to access lazy loaded attributes I get a LazyInitializationException.
So question 2: Is there a way to 'reatach' the object to a new session, so the Lazy Load succeeds?
Thanks for any help.
Jens