【发布时间】:2014-04-18 04:36:54
【问题描述】:
环境:
-
apache tomcat 7
-
java 7
-
甲骨文 11g
-
日食
-
apache jmeter 2.1
-
春天
-
休眠
我正在开发一个 Web 应用程序,它接收来自客户端的请求并根据请求类型为它们生成序列号以用于进一步处理。 为了生成唯一的序列号,我有一种方法可以从数据库中获取当前序列号并将其递增 1,然后用新的序列号更新该记录。
功能:
@Transactional
public synchronized Long generateSequenseNumber(String requestType) {
//get current sequence number for this requestType
//increment it by one
//update it in DB
}
该功能工作正常,但问题是当我从压力测试工具 (JMeter) 调用应用程序以每秒发送 50 个请求时,我得到以下异常:
org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [
虽然函数是同步的。
任何建议都会有所帮助。谢谢。
【问题讨论】:
标签: hibernate tomcat spring-mvc jmeter