以下程序代码对Customer的name属性修改了两次,为什么只发一条update语句?tx = session.beginTransaction(); Customer customer=(Customer)session.load(Customer.class, new Long(1)); customer.setName(\"Jack\"); customer.setName(\"Mik

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/30 12:15:24
以下程序代码对Customer的name属性修改了两次,为什么只发一条update语句?tx = session.beginTransaction();  Customer customer=(Customer)session.load(Customer.class,  new Long(1));  customer.setName(\

以下程序代码对Customer的name属性修改了两次,为什么只发一条update语句?tx = session.beginTransaction(); Customer customer=(Customer)session.load(Customer.class, new Long(1)); customer.setName(\"Jack\"); customer.setName(\"Mik
以下程序代码对Customer的name属性修改了两次,为什么只发一条update语句?
tx = session.beginTransaction(); Customer customer=(Customer)session.load(Customer.class, new Long(1)); customer.setName(\"Jack\"); customer.setName(\"Mike\"); tx.commit(); 虽然Load是使用时才发SQL语句,但是它不是使用了2次吗

以下程序代码对Customer的name属性修改了两次,为什么只发一条update语句?tx = session.beginTransaction(); Customer customer=(Customer)session.load(Customer.class, new Long(1)); customer.setName(\"Jack\"); customer.setName(\"Mik
hibernate的load是在缓存中抓数据所以没有执行sql 缓存中没有这条数据 才会去数据库中找
希望采纳