本帖最后由 huixx 于 2009-11-27 17:34:54 编辑

解决方案 »

  1.   

    2009-11-27 17:07:06,031 [http-8080-2] WARN  [org.hibernate.util.JDBCExceptionReporter] - SQL Error: 1213, SQLState: 40001
    2009-11-27 17:07:06,031 [http-8080-2] ERROR [org.hibernate.util.JDBCExceptionReporter] - Deadlock found when trying to get lock; try restarting transaction
    2009-11-27 17:07:06,031 [http-8080-2] ERROR [org.hibernate.event.def.AbstractFlushingEventListener] - Could not synchronize database state with session这时错误,在加了@Transactional(readOnly = false, propagation = Propagation.REQUIRED, isolation = Isolation.SERIALIZABLE)
      

  2.   

    嗯,mysql事务支持本身就不是很好,楼主用的是MYSQL什么引擎,INNODB才支持事务
      

  3.   

    给mysql提意见,加上和oracle一样的nowait的参数,直接报错胡说bdgood luck
      

  4.   

    不知楼主如何模拟这种场景,如何区分这快一点和慢一点,还有在oracle下是否报一样的错?大家一起探讨下。
      

  5.   

    能不能具体说一下用spring2.5如何实现,基于spring的hibernateTamplate,非常感谢
      

  6.   

    这个快一点和慢一点是这两个买书事务的查询sql语句谁先提交到数据库的,谁先到,谁就快,
    我是用springside声明1个服务,在服务中写了一个函数来模拟的,在网页中多次异步调用这个函数,函数前加了@Transactional(readOnly = false, propagation = Propagation.REQUIRED, isolation = Isolation.SERIALIZABLE)
      

  7.   

    为了模式并发,在函数中加了tread.Sleep(10000).