Environment:
- apache tomcat 7
- java 7
- oracle 11g
- eclipse
- apache jmeter 2.1
- spring
sleep mode
I am working on a web application that receives requests from clients and generates a sequence number for them according to the type of request that will be used for further processing. To generate a unique serial number, I have a way to get the current serial number from the database and increase it by 1, and then update this record with a new serial number.
Function:
@Transactional
public synchronized Long generateSequenseNumber(String requestType) {
}
The function works fine, but the problem is that I call the application from the stress testing tool (JMeter) to send 50 requests per second. I get below exceptions:
org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [
although the function is synchronized.
Any suggestion would be helpful. Thank.