List of usage examples for org.hibernate LockOptions UPGRADE
LockOptions UPGRADE
To view the source code for org.hibernate LockOptions UPGRADE.
Click Source Link
From source file:ch.algotrader.dao.AbstractDao.java
License:Open Source License
public E getLocked(long id) { return get(id, LockOptions.UPGRADE); }
From source file:ch.algotrader.dao.AbstractDao.java
License:Open Source License
public E loadLocked(long id) { return load(id, LockOptions.UPGRADE); }
From source file:ch.algotrader.dao.AbstractDao.java
License:Open Source License
public void lock(E entity) { lock(entity, LockOptions.UPGRADE); }
From source file:ch.algotrader.dao.AbstractDaoTest.java
License:Open Source License
@Test public void testLockEntity() throws Exception { GenericItem stuff1 = new GenericItem("this"); stuff1.setActive(true);/*from ww w . ja v a 2 s . c o m*/ stuff1.setBroker(Broker.DC.name()); this.dao.save(stuff1); long id1 = stuff1.getId(); Assert.assertNotEquals(0, id1); this.dao.flush(); this.dao.lock(stuff1, LockOptions.UPGRADE); }
From source file:ch.algotrader.dao.PositionDaoImpl.java
License:Open Source License
@Override public Position findBySecurityAndStrategyIdLocked(long securityId, long strategyId) { return findUnique(LockOptions.UPGRADE, "Position.findBySecurityAndStrategyIdLocked", QueryType.BY_NAME, new NamedParam("securityId", securityId), new NamedParam("strategyId", strategyId)); }
From source file:ch.algotrader.dao.strategy.CashBalanceDaoImpl.java
License:Open Source License
@Override public CashBalance findByStrategyAndCurrencyLocked(Strategy strategy, Currency currency) { Validate.notNull(strategy, "Strategy is null"); Validate.notNull(currency, "Currency is null"); return findUnique(LockOptions.UPGRADE, "CashBalance.findByStrategyAndCurrencyLocked", QueryType.BY_NAME, new NamedParam("strategy", strategy), new NamedParam("currency", currency)); }
From source file:com.book.identification.dao.GenericHibernateDAO.java
License:Apache License
/** * Busca por Id//from w ww. jav a2s . c o m * * @param id * @return */ @SuppressWarnings("unchecked") public T findById(ID id, boolean lock) { T entity; if (lock) entity = (T) this.getSession().load(getPersistentClass(), id, LockOptions.UPGRADE); else { entity = (T) this.getSession().load(getPersistentClass(), id); } return entity; }
From source file:com.globalsight.ling.tm3.core.BaseTm.java
License:Apache License
void lockForWrite() throws TM3Exception { if (!locked) { getSession().buildLockRequest(LockOptions.UPGRADE).lock(this); //getSession().lock(this, LockMode.UPGRADE); locked = true;/*from ww w . j a v a2 s .c o m*/ } }
From source file:com.heimaide.server.common.persistence.BaseDao.java
License:Open Source License
/** * ??/*from w w w . j a va2 s . c o m*/ * * @param id * @return */ @SuppressWarnings("unchecked") public T getWithLock(Serializable id) { String hql = "from " + entityClass.getSimpleName() + " where id = :p1"; Query query = createQuery(hql, new Parameter(id)); query.setLockOptions(LockOptions.UPGRADE); return (T) query.uniqueResult(); }
From source file:com.hibernate.annotation.repository.base.GenericHibernateDAO.java
@SuppressWarnings("unchecked") public T findById(ID id, boolean lock) { T entity;/*from ww w .ja v a2s . c o m*/ if (lock) { entity = (T) getSession().load(getPersistentClass(), id, LockOptions.UPGRADE); } else { entity = (T) getSession().load(getPersistentClass(), id); } return entity; }