List of usage examples for com.liferay.portal.kernel.dao.orm LockMode UPGRADE
LockMode UPGRADE
To view the source code for com.liferay.portal.kernel.dao.orm LockMode UPGRADE.
Click Source Link
From source file:com.liferay.counter.service.persistence.CounterFinderImpl.java
License:Open Source License
private CounterHolder _obtainIncrement(String counterName, long range, long size) throws SystemException { Session session = null;/* w w w . j a va2 s . c o m*/ try { session = openSession(); Counter counter = (Counter) session.get(CounterImpl.class, counterName, LockMode.UPGRADE); long newValue = counter.getCurrentId(); if (size > newValue) { newValue = size; } long rangeMax = newValue + range; counter.setCurrentId(rangeMax); CounterHolder counterHolder = new CounterHolder(newValue, rangeMax); session.saveOrUpdate(counter); session.flush(); return counterHolder; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } }