It finally works by changing
Quote:
Session session1 = sessionFactory.openSession();
Session session2 = sessionFactory.openSession();
Long id = new Long(1);
MyObject obj1 = (MyObject) session1.get(MyObject.class, id);
MyObject obj2 = (MyObject) session2.get(MyObject.class, id);
to
Quote:
Session session1 = sessionFactory.openSession();
Long id = new Long(1);
MyObject obj1 = (MyObject) session1.get(MyObject.class, id);
Session session2 = sessionFactory.openSession();
MyObject obj2 = (MyObject) session2.get(MyObject.class, id);
ie opening the second session AFTER the object was put in jvm cache.
I have another problem :
If I change the working example, opening sessions with
Session session2 = sessionFactory.openSession(c);
..
Session session1 = sessionFactory.openSession(c);
(I provide a connection)
It stop working.