by florin 18 Feb 16:52
javax.persistence.OptimisticLockException: Data has changed. updated [0] rows

Why would I get that?

I have a master detail situation where I take one row in a popup to view/edit details.

The first update operation works fine, the subsequent once give me this error. Could it be that the transaction is not closed between submit actions?

19 Feb 04:44
by Rob

Best approach is to look in the transaction logs with the update statement and bind values.

In updating 0 rows there is something wrong in the where clause of the update. So you are specifically looking at the bind values in the where clause of the update (to see why 0 rows where updated).

You need to see whether you are using a version column and whether it is a timestamp (as opposed to an integer). If it is a timestamp then there may be something fishy with the timestamp precision so then I'd ask what you DB is.

> Could it be that the transaction is not closed between submit actions?
Ummm... you want to make sure that the first transaction was committed (or more accurately not rolled back or failed).

You can see the transaction demarcation in the transaction logs... but you could also turn on the transaction debug to have the demarcation commit/rollback events logged to system out (with some summary level information such as number of beans inserted/updated/deleted.

... but the place to look is the where clause of the update statement in the transaction logs.

Create a New Topic

Title:
Body:
 
Introduction User Guide (pdf) Install/Configure Public JavaDoc Whitepapers
General Database Specific Byte Code Deployment Annotations Features
Top Bugs Top Enhancements
woResponse