浏览 2938 次
精华帖 (0) :: 良好帖 (0) :: 灌水帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2007-01-19
引用 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 = ![]() 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. 希望管理员以后可以认真考量问题的技术含量!再次谢谢! 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2007-01-19
补充一点在我实际的测试中versioned关键字并不被接受!会出现语法错误顾发此帖...
|
|
返回顶楼 | |
发表时间:2007-01-19
不就是一个帖子的事嘛,别较真
|
|
返回顶楼 | |
发表时间:2007-01-19
damies 写道 希望管理员以后可以认真考量问题的技术含量!再次谢谢!
这可不是管理员干的,这是大家投票的结果,民意如此! |
|
返回顶楼 | |
发表时间:2007-01-19
|
|
返回顶楼 | |