- Posts: 18
- Joined: Sun Jun 21, 2015 2:56 am
could you clarify explanation to option 2? I think these statements:
it must throw the PersistenceException
it is possible that Persistence exception will be thrown but not necessarily
are in conflict.
- Site Admin
- Posts: 8703
- Joined: Fri Sep 10, 2010 9:26 pm
No, they are not. The first statement is talking about a general rule about non-versioned object. If an entity is non-version and if the container doesn't support locking for it, then it must throw PersistenceException.
The second statement is talking about a possibility because a container may choose to support locking on a non-versioned object and in that case there will be no exception. In this question, we don't know whether the container supports it or not and therefore we don't know for sure if there will be an exception.
If you like our products and services, please help us by posting your review here
- Posts: 358
- Joined: Fri Nov 29, 2013 8:26 pm
In option 3 explanation:
The issue of version check arises only when you request a pessimistic lock.
I think version check also arises when we request an optimistic lock.
So, OptimisticLockException can be thrown in this case em.lock(obj, LockModeType.OPTIMISTIC_FORCE_INCREMENT);
Users browsing this forum: No registered users and 1 guest