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:org.zht.framework.zhtdao.hibernate.impl.HibernateBaseDaoImpl.java
License:Apache License
@SuppressWarnings("unchecked") @Override//from ww w.java 2s . com public <E> E findAndLock(Class<E> clazz, Serializable id) throws DaoException { if (id == null) { return null; } E entity = (E) this.getCurrentSession().get(clazz, id, LockOptions.UPGRADE); if (entity == null) { return null; } return entity; }
From source file:robertli.zero.dao.impl.GenericHibernateDao.java
License:MIT License
@Override public T getForUpdate(PK id) { return (T) getSession().get(entityClass, id, LockOptions.UPGRADE); }
From source file:ubic.gemma.persistence.service.expression.arrayDesign.ArrayDesignDaoImpl.java
License:Apache License
@Override public void deleteGeneProductAssociations(ArrayDesign arrayDesign) { this.getSessionFactory().getCurrentSession().buildLockRequest(LockOptions.UPGRADE) .setLockMode(LockMode.PESSIMISTIC_WRITE).lock(arrayDesign); // this query is polymorphic, id gets the annotation associations? //language=HQL final String queryString = "select ba from CompositeSequence cs " + "inner join cs.biologicalCharacteristic bs, BioSequence2GeneProduct ba " + "where ba.bioSequence = bs and cs.arrayDesign=:arrayDesign"; List blatAssociations = this.getSessionFactory().getCurrentSession().createQuery(queryString) .setParameter("arrayDesign", arrayDesign).list(); if (!blatAssociations.isEmpty()) { for (Object r : blatAssociations) { this.getSessionFactory().getCurrentSession().delete(r); }// w w w . j a v a 2 s. co m AbstractDao.log .info("Done deleting " + blatAssociations.size() + " blat associations for " + arrayDesign); } this.getSessionFactory().getCurrentSession().flush(); final String annotationAssociationQueryString = "select ba from CompositeSequence cs " + " inner join cs.biologicalCharacteristic bs, AnnotationAssociation ba " + " where ba.bioSequence = bs and cs.arrayDesign=:arrayDesign"; //noinspection unchecked List<AnnotationAssociation> annotAssociations = this.getSessionFactory().getCurrentSession() .createQuery(annotationAssociationQueryString).setParameter("arrayDesign", arrayDesign).list(); if (!annotAssociations.isEmpty()) { for (AnnotationAssociation r : annotAssociations) { this.getSessionFactory().getCurrentSession().delete(r); } AbstractDao.log.info( "Done deleting " + annotAssociations.size() + " AnnotationAssociations for " + arrayDesign); } }