It sounds like you have a race condition related to transaction issues. Your second request for the same, but edited object is coming through and being satisfied before the transaction of your first request commits. Essentially your transaction should be complete and your work committed before step #4 completes.
Without having explicitly-defined transaction start/end, you might be at the whim of the connection pool release/auto-commit or JVM garbage collection as to the precise moment when your transaction commits. I can't really comment further without knowing how you're managing transactions or whether or not you're using JTA. Personally I use Spring with a local (non-jta) transaction manager, and do transaction demarcation in my service layer (per-method) so it's clear which methods are write, which methods are read-only, and when my work will be committed to the database.
|