Search code examples
springjakarta-eejpaejbopenjpa

Get Unable to obtain an object lock on "null".; org.apache.openjpa.persistence.OptimisticLockException:


This is a Spring application with Roo and the exception thrown by a simple finder function like:

 TransactionRate.findAllTransactionRate(TransactionRate.java:1)

The exception only happens to TransactionRate entity but not the other 20 entities. I am pretty sure their is no other entityManager is reading/editing on the entity so that table should not be locked. The persistent.xml looks clear.

I used to have similar issue but just remember the solution is to change something else in configuration(like persistence.xml), really cannnot recall details.

Please share any ideas. Thank you.


Solution

  • Turns out there are three new fields added to the entity but not updated in database schema, hence the exception from Openjpa, leave this answer for the record.