Page 1 of 1

About Question enthuware.oce-jpad.v6.2.366 :

Posted: Fri Apr 07, 2017 3:40 pm
by unvector
Hi,

could you clarify explanation to option 2? I think these statements:
it must throw the PersistenceException
and
it is possible that Persistence exception will be thrown but not necessarily
are in conflict.

Re: About Question enthuware.oce-jpad.v6.2.366 :

Posted: Fri Apr 07, 2017 9:58 pm
by admin
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.

Re: About Question enthuware.oce-jpad.v6.2.366 :

Posted: Sat Jul 08, 2017 11:12 pm
by himaiMinh
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);