Hibernate 版本控制问题-原版本号被置null。

guangwuzhongxing 2007-12-28 04:24:15
请教各位高手,
我使用spring+hibernate作项目。
hibernate位置文件:

<class name="com.game.products.model.Products" table="T_PRODUCTS" optimistic-lock="version" >

<id name="gameId" type="string">
<column name="GAME_ID" length="50" />
<generator class="assigned" />
</id>
<timestamp name ="gameUpdateTime" column ="GAME_UPDATE_TIME" />
.....

我的数据库中某条记录的时间为:2007-12-28 10:12:001
在我对这个数据进行更新的时候,提示本条记录修改过。我可以确认只有我一个人操作。
操了一个hibernate的debug信息。发现 在初始化的时候,可以得到这个版本号。但是就是在update之前 这个版本号居然为:null
这是hibernate 到数据库里找原来版本号为null的就找不到 所以才报错。
我现在极其郁闷的是 不知道这个本本号什么时候变成的null! 请各位指点!

参考信息:错误信息 ---表明版本被修改
javax.servlet.ServletException: Object of class [com.game.products.model.Products] with identifier [0004]: optimistic locking failed; nested exception is org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [com.game.products.model.Products#0004]


debug信息:
DEBUG - Flushing entities and processing referenced collections
DEBUG - get time:2007-12-28 13:02:23.647 -------------此处还正常时间为上次的时间戳
.................
EBUG - Updating entity: [com.game.products.model.Products#0004]
DEBUG - Existing version: null -> New version: 2007-12-28 16:15:36.458 --------------此处之前的某处不知什么原因 现有的版本号为null
DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG - opening JDBC connection
Hibernate: update T_PRODUCTS set GAME_UPDATE_TIME=?, GAME_NAME_CN=?, GAME_NAME_EN=?, GAME_CAPACITY=?, GAME_VERSION=?, GAME_MEDIA=?, GAME_COPYRIGHE=?, GAME_PRICE=?, GAME_CONTENT=? where GAME_ID=? and GAME_UPDATE_TIME=?
DEBUG - preparing statement
DEBUG - Dehydrating entity: [com.game.products.model.Products#0004]
DEBUG - binding '2007-12-28 16:15:36' to parameter: 1
DEBUG - binding 'TestName' to parameter: 2
DEBUG - binding 'TestEname' to parameter: 3
DEBUG - binding '2' to parameter: 4
DEBUG - binding '1' to parameter: 5
DEBUG - binding '1' to parameter: 6
DEBUG - binding '1' to parameter: 7
DEBUG - binding '80' to parameter: 8
DEBUG - binding 'Just a test' to parameter: 9
DEBUG - binding '0004' to parameter: 10
DEBUG - binding null to parameter: 11 ----------------此处为null

...全文
172 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧