hibernate - OptimisticLock Trying update the same object again -


i'm getting below exception:

org.hibernate.staleobjectstateexception: row updated or deleted transaction (or unsaved-value mapping incorrect): [

it happens when try update object using form again. in first time works when try update same object again got exception.

could flush in session ?

here entity
@persistencecontext(unitname = "jpaservice", type = persistencecontexttype.extended) private entitymanager nasc;

here service: @stateless @transactionattribute(transactionattributetype.required) @transactionmanagement(transactionmanagementtype.container)

thank you!

optimistic locking works following way: have version field in entity (annotated @version). load entity, , (for example), version field has value 33. save entity. hibernate checks version value in entity (33) matches 1 in table. if not, throws exception. if match, increments versions, in entity , in database.

so, if save entity once again, still gets values form still contains old version value (33), you'll exception. make sure refresh form object up-to-date values of entity, including version field.

it's impossible give more details without code, should enable debug , see bug is.


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -