i want to get the same entities upon the ID, such as follows:
Code:
Userlist ul1= (Userlist)session.get(Userlist.class, new Integer(1));
Userlist ul2= (Userlist)session.get(Userlist.class, new Integer(1));
assertEquals(ul1, ul2);
The test can pass and ul1 is equal to ul2 as objects.
However, if the objects are created from different sessions, the test can not pass, as this:
Code:
Session session1 =HibernateUtil.getSessionFactory().openSession();
Session session2 =HibernateUtil.getSessionFactory().openSession();
Userlist ul1= (Userlist)session1.get(Userlist.class, new Integer(1));
Userlist ul2= (Userlist)session2.get(Userlist.class, new Integer(1));
assertEquals(ul1, ul2);
So, my question: is there any method that can allow me created entities from different sessions?
Or if I use the just one session for the whole application, what gonna happen for the system performance? slow?
thanks