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

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/02 04:34:32

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

以下程序代码对Customer的name属性修改了两次:tx = session.beginTransaction(); Customer customer=(Customer)session.load(Customer.class,new Long(1)); customer.setName(\"Jack\"); customer.setName(\"Mike\"); tx.commit(); 为什么只发一
load时,只是查,不是影响操作的
是1条的update语句的,因为只有commit() 执行,才是真正的提交sql
还有事务未提交,sql操作语句一句都不会真正影响数据库