updateData() , . , updateData(). Hibernate JPA, :
updateData() {
Object obj = getData(id);
Session session = (Session) em.getDelegate();
session.refresh(obj, LockMode.UPGRADE);
}
An update is necessary because it may happen that between the retrieval and locking of the data, another transaction completes at updateData.
Keep in mind that the object manager used in getDataand updateDatamust be the same.
source
share