java - How can I get an OptimsticLockException instead of a StaleObjectStateException in Hibernate 4? -


the desire catch ole instead of sose less tightly coupled hibernate in case ever needed change jpa providers.

the case producing exception straightforward; i've breakpointed before versioned entity update committed, committed change directly in db, , allowed execution continue.

it looks staleobjectstateexception vs optimisticlockexception answer should "use jpa annotations", doing that. specifically, entity in question imports annotations javax.persistence.*

it turns out because using hibernate session objects rather entitymanagers - hibernate doesn't check jpa annotations (and wrap soses in oles if present) unless entitymanager being used.

we can't fix because dropwizard uses sessions, understand why happening , happen consistently, can catch sose , issue resolved.


Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -