Importing javax.persistence API into cuba

Good day

I want to make use of the javax.persistence API to get the lock functionalities, in order to lock the table record that a certain user is busy editing in my application.
Imports:
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.LockModeType;
import javax.persistence.Persistence;

Is it possible to do so?

Thank you in advance

Hi,

Try to obtain javax.persistence.EntityManager from CUBA EntityManager:

javax.persistence.EntityManager entityManager = persistence.getEntityManager().getDelegate();
entityManager.lock(entity, LockModeType.PESSIMISTIC_WRITE);