List of usage examples for org.hibernate Session getCurrentLockMode
LockMode getCurrentLockMode(Object object);
From source file:com.jaspersoft.jasperserver.api.metadata.common.service.impl.hibernate.HibernateRepositoryServiceImpl.java
License:Open Source License
protected void lockReadFolder(RepoFolder folder) { HibernateTemplate template = getHibernateTemplate(); Session session = template.getSessionFactory().getCurrentSession(); LockMode folderLockMode = session.getCurrentLockMode(folder); if (LockMode.READ.equals(folderLockMode)) { String currentURI = folder.getURI(); //refresh and lock the parent template.refresh(folder, LockMode.UPGRADE); //check whether the parent URI has changed if (!currentURI.equals(folder.getURI())) { throw new JSException("jsexception.folder.moved", new Object[] { currentURI, folder.getURI() }); }/* ww w . j ava 2s . c o m*/ } }
From source file:org.jpos.transaction.DebugDB.java
License:Open Source License
@Override public int prepare(long id, Serializable context) { Context ctx = (Context) context; DB db = (DB) ctx.get(TxnConstants.DB); Session session = db.session(); SessionStatistics statistics = session.getStatistics(); Set<EntityKey> entityKeys = statistics.getEntityKeys(); ctx.log(String.format("ENTITIES: (%d)", statistics.getEntityCount())); for (EntityKey ek : entityKeys) { Object obj = session.get(ek.getEntityName(), ek.getIdentifier()); LockMode lockMode = session.getCurrentLockMode(obj); ctx.log(String.format("[%s] %s %s", ek.getIdentifier(), ek.getEntityName(), lockMode)); }//w w w . j a va 2s. c o m ctx.log("==== COLLECTIONS ===="); Set<CollectionKey> collectionKeys = statistics.getCollectionKeys(); for (CollectionKey ck : collectionKeys) { ctx.log(String.format("[%s] %s", ck.getKey(), ck.getRole())); } ctx.log("====================="); return PREPARED | READONLY | NO_JOIN; }