您的位置:程序门 -> java -> 架构、设计



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


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


hibernate 版本控制问题-原版本号被置null。
发表于:2007-12-28 16:19:48 楼主
请教各位高手,
我使用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



快速检索

最新资讯
热门点击