论坛首页 海阔天空论坛

我觉得我的那个帖子不是新手帖是一个事实在在的技术问题,也可能是很多人没有注意到的

浏览 2924 次
精华帖 (0) :: 良好帖 (0) :: 灌水帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2007-01-19  
我可以确定的是那不是个新手问题,关于DML方式去批量更新的时候不可以对乐观锁中的version进行同步,请看看Hibernate Reference中对这部分的说明:
引用

HQL UPDATE statements, by default do not effect the Section 5.1.7, “version (optional)” or the Section 5.1.8,
“timestamp (optional)” property values for the affected entities; this is in keeping with the EJB3 specification.
However, you can force Hibernate to properly reset the version or timestamp property values through the use
of a versioned update. This is achieved by adding the VERSIONED keyword after the UPDATE keyword.
Session session = sessionFactory.openSession();
Transaction tx = session.beginTransaction();
String hqlVersionedUpdate = "update versioned Customer set name = :newName where name =ldName";
int updatedEntities = s.createQuery( hqlUpdate )
.setString( "newName", newName )
.setString( "oldName", oldName )
.executeUpdate();
tx.commit();
session.close();
Note that custom version types (org.hibernate.usertype.UserVersionType) are not allowed in conjunction
with a update versioned statement.

希望管理员以后可以认真考量问题的技术含量!再次谢谢!
   发表时间:2007-01-19  
补充一点在我实际的测试中versioned关键字并不被接受!会出现语法错误顾发此帖...
0 请登录后投票
   发表时间:2007-01-19  
不就是一个帖子的事嘛,别较真
0 请登录后投票
   发表时间:2007-01-19  
damies 写道
希望管理员以后可以认真考量问题的技术含量!再次谢谢!


这可不是管理员干的,这是大家投票的结果,民意如此!
0 请登录后投票
   发表时间:2007-01-19  
地址加上!
PS:如果你不知道怎么写新手贴,去看看:
http://www.iteye.com/post/156572
你犯了N条了。。。
0 请登录后投票
论坛首页 海阔天空版

跳转论坛:
Global site tag (gtag.js) - Google Analytics