List of usage examples for org.hibernate LockOptions LockOptions
public LockOptions(LockMode lockMode)
From source file:org.obiba.opal.core.upgrade.v2_0_x.database.FixAttributeJoinTableUpgradeStep.java
License:Open Source License
@SuppressWarnings("unchecked") private void touchValueTablesTimestamps(final Database database) { transactionTemplate.execute(new TransactionCallbackWithoutResult() { @Override//from w w w . jav a2 s . com protected void doInTransactionWithoutResult(TransactionStatus status) { SessionFactory sessionFactory = databaseRegistry.getSessionFactory(database.getName(), null); Session currentSession = sessionFactory.getCurrentSession(); for (ValueTableState table : (List<ValueTableState>) currentSession .createCriteria(ValueTableState.class).list()) { log.debug("Touch {} last update", table.getName()); currentSession.buildLockRequest(new LockOptions(LockMode.PESSIMISTIC_FORCE_INCREMENT)) .lock(table); } } }); }
From source file:org.springframework.orm.hibernate4.HibernateTemplate.java
License:Apache License
@Override public <T> T get(final Class<T> entityClass, final Serializable id, final LockMode lockMode) throws DataAccessException { return executeWithNativeSession(new HibernateCallback<T>() { @Override//w ww . j a v a2s. c o m @SuppressWarnings("unchecked") public T doInHibernate(Session session) throws HibernateException { if (lockMode != null) { return (T) session.get(entityClass, id, new LockOptions(lockMode)); } else { return (T) session.get(entityClass, id); } } }); }
From source file:org.springframework.orm.hibernate4.HibernateTemplate.java
License:Apache License
@Override public Object get(final String entityName, final Serializable id, final LockMode lockMode) throws DataAccessException { return executeWithNativeSession(new HibernateCallback<Object>() { @Override//from ww w. ja v a 2s .com public Object doInHibernate(Session session) throws HibernateException { if (lockMode != null) { return session.get(entityName, id, new LockOptions(lockMode)); } else { return session.get(entityName, id); } } }); }
From source file:org.springframework.orm.hibernate4.HibernateTemplate.java
License:Apache License
@Override public <T> T load(final Class<T> entityClass, final Serializable id, final LockMode lockMode) throws DataAccessException { return executeWithNativeSession(new HibernateCallback<T>() { @Override//from w w w . ja v a 2 s. co m @SuppressWarnings("unchecked") public T doInHibernate(Session session) throws HibernateException { if (lockMode != null) { return (T) session.load(entityClass, id, new LockOptions(lockMode)); } else { return (T) session.load(entityClass, id); } } }); }
From source file:org.springframework.orm.hibernate4.HibernateTemplate.java
License:Apache License
@Override public Object load(final String entityName, final Serializable id, final LockMode lockMode) throws DataAccessException { return executeWithNativeSession(new HibernateCallback<Object>() { @Override//from w w w .ja v a2 s. c om public Object doInHibernate(Session session) throws HibernateException { if (lockMode != null) { return session.load(entityName, id, new LockOptions(lockMode)); } else { return session.load(entityName, id); } } }); }
From source file:org.springframework.orm.hibernate4.HibernateTemplate.java
License:Apache License
@Override public void refresh(final Object entity, final LockMode lockMode) throws DataAccessException { executeWithNativeSession(new HibernateCallback<Object>() { @Override/*from w w w . j a v a 2 s . co m*/ public Object doInHibernate(Session session) throws HibernateException { if (lockMode != null) { session.refresh(entity, new LockOptions(lockMode)); } else { session.refresh(entity); } return null; } }); }
From source file:org.springframework.orm.hibernate4.HibernateTemplate.java
License:Apache License
@Override public void lock(final Object entity, final LockMode lockMode) throws DataAccessException { executeWithNativeSession(new HibernateCallback<Object>() { @Override//from w w w .j a va 2 s. c o m public Object doInHibernate(Session session) throws HibernateException { session.buildLockRequest(new LockOptions(lockMode)).lock(entity); return null; } }); }
From source file:org.springframework.orm.hibernate4.HibernateTemplate.java
License:Apache License
@Override public void lock(final String entityName, final Object entity, final LockMode lockMode) throws DataAccessException { executeWithNativeSession(new HibernateCallback<Object>() { @Override//from w w w . jav a2 s . co m public Object doInHibernate(Session session) throws HibernateException { session.buildLockRequest(new LockOptions(lockMode)).lock(entityName, entity); return null; } }); }
From source file:org.springframework.orm.hibernate4.HibernateTemplate.java
License:Apache License
@Override public void update(final Object entity, final LockMode lockMode) throws DataAccessException { executeWithNativeSession(new HibernateCallback<Object>() { @Override//from w w w. jav a 2s. c o m public Object doInHibernate(Session session) throws HibernateException { checkWriteOperationAllowed(session); session.update(entity); if (lockMode != null) { session.buildLockRequest(new LockOptions(lockMode)).lock(entity); } return null; } }); }
From source file:org.springframework.orm.hibernate4.HibernateTemplate.java
License:Apache License
@Override public void update(final String entityName, final Object entity, final LockMode lockMode) throws DataAccessException { executeWithNativeSession(new HibernateCallback<Object>() { @Override//from w w w . j a va 2 s .c o m public Object doInHibernate(Session session) throws HibernateException { checkWriteOperationAllowed(session); session.update(entityName, entity); if (lockMode != null) { session.buildLockRequest(new LockOptions(lockMode)).lock(entityName, entity); } return null; } }); }