List of usage examples for org.hibernate Query setLockOptions
Query<R> setLockOptions(LockOptions lockOptions);
From source file:org.yes.cart.dao.impl.GenericDAOHibernateImpl.java
License:Apache License
/** * {@inheritDoc}// w w w . j a v a 2s . c o m */ @SuppressWarnings("unchecked") public List<T> findByNamedQueryForUpdate(final String namedQueryName, final int timeout, final Object... parameters) { Query query = sessionFactory.getCurrentSession().getNamedQuery(namedQueryName); LockOptions opts = new LockOptions(LockMode.PESSIMISTIC_WRITE); opts.setTimeOut(timeout); query.setLockOptions(opts); if (parameters != null) { setQueryParameters(query, parameters); } return query.list(); }