2012-02-28 126 views
0
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:我们是否在会话高速缓存中保存相同的表对象,或者我们可以在同一个会话中保存两个不同的表对象。休眠一级高速缓存

谢谢

+1

我不明白你的问题。 – 2012-02-28 11:46:53

回答

1

这取决于映射。如果Student从Person继承并且以这种方式映射,那么第二个session.get将返回相同的实例。