Reputation: 3327
Session ses = factory.openSession();
Student s = (Student)ses.get(Student.class, new Integer(101));
System.out.println(s.getStudentId());
Hi
Person p = (Person)ses.get(Person.class, new Integer(101));
System.out.println(p.getPerson());
ses.close();
Q1: Whether we save same table object in the session cache or we can save two differnt table objects in the same session.
Thank you
Upvotes: 0
Views: 156
Reputation: 30813
It depends of the mapping. If Student inherits from Person and is mapped that way then the second session.get will return the same instance.
Upvotes: 1