EclipseLink in ACT give a warning log about org.eclipse.persistence.exceptions.OptimisticLockException, but throw java.lang.IllegalStateException at final.
So, the OptimisticLockException could not be caught in the program and can get the OptimisticLockException error message.
2018-07-03 11:24:05,198 DEBUG [XNIO-1 task-3] [eclipselink.logging.sql] - UPDATE bb_admin SET last_update = ?, VERSION = ? WHERE ((ID = ?) AND (VERSION = ?))
bind => [2018-07-03 11:24:05.197, 6, 10, 5]
2018-07-03 11:24:05,202 WARN [XNIO-1 task-3] [eclipselink.logging.all] - Exception [EclipseLink-5011] (Eclipse Persistence Services - 2.7.1.v20171221-bd47e8f): org.eclipse.persistence.exceptions.OptimisticLockException
Exception Description: One or more objects cannot be updated because it has changed or been deleted since it was last read
2018-07-03 11:24:05,207 ERROR [XNIO-1 task-3] [act.handler.builtin.controller.RequestHandlerProxy] - Error handling request: [PATCH] /api/admin/10
java.lang.IllegalStateException: Not in a TX scope
at org.osgl.util.E.illegalStateIf(E.java:753)
at act.db.sql.tx.TxContext.exitTxScope(TxContext.java:66)
at act.db.sql.tx.TxScopeHelper.exit(TxScopeHelper.java:39)
at cc.bable.nexus.api.AdminEndpoint.updateAdmin(AdminEndpoint.java:109)
Reproduce step:
Create a JPA entity with @Version
@Version
public Long version;
Update the JPA entity with out of date version value
For example:
version in DB is 3.
POST the update version as 2.
EclipseLink in ACT give a warning log about org.eclipse.persistence.exceptions.OptimisticLockException, but throw java.lang.IllegalStateException at final. So, the OptimisticLockException could not be caught in the program and can get the OptimisticLockException error message.
Reproduce step: