【发布时间】:2014-07-07 04:59:24
【问题描述】:
我想知道 Hibernate 内部是如何工作的。
所以,我在 DB 里有个叫“Peter”的人;
Session session = SessionFactory.openSession();
Person p = session.get(Person.class, 1);//Peter's id is 1
System.out.println(p.getName());//output : Peter
p.setName("Joey");
session.flush();
session.close();
现在这个人在 DB 中的名字已更改为“Joey”。
这是怎么发生的?
当我更改此人的姓名时。 hibernate 是如何检测到这些变化的?
【问题讨论】:
-
@SajanChandran 怎么样,hibernate 什么时候检测到的?
-
此链接解释了howhibernate 检测更改并执行适当的查询。