List of usage examples for org.hibernate LockOptions NONE
LockOptions NONE
To view the source code for org.hibernate LockOptions NONE.
Click Source Link
From source file:ubic.gemma.persistence.service.analysis.expression.diff.ExpressionAnalysisResultSetDaoImpl.java
License:Apache License
@Override public void remove(ExpressionAnalysisResultSet resultSet) { // Wipe references resultSet.setResults(new HashSet<DifferentialExpressionAnalysisResult>()); this.update(resultSet); // Clear session Session session = this.getSessionFactory().getCurrentSession(); session.flush();/*w w w.j a va2 s.c o m*/ session.clear(); session.buildLockRequest(LockOptions.NONE).lock(resultSet); int contrastsDone = 0; int resultsDone = 0; // Remove results - Not using DifferentialExpressionResultDaoImpl.remove() for speed { AbstractDao.log.info("Bulk removing dea results..."); // Delete contrasts //language=MySQL final String nativeDeleteContrastsQuery = "DELETE c FROM CONTRAST_RESULT c, DIFFERENTIAL_EXPRESSION_ANALYSIS_RESULT d" + " WHERE d.RESULT_SET_FK = :rsid AND d.ID = c.DIFFERENTIAL_EXPRESSION_ANALYSIS_RESULT_FK"; SQLQuery q = session.createSQLQuery(nativeDeleteContrastsQuery); q.setParameter("rsid", resultSet.getId()); contrastsDone += q.executeUpdate(); // cannot use the limit clause for this multi-table remove. // Delete AnalysisResults //language=MySQL String nativeDeleteARQuery = "DELETE d FROM DIFFERENTIAL_EXPRESSION_ANALYSIS_RESULT d WHERE d.RESULT_SET_FK = :rsid "; q = session.createSQLQuery(nativeDeleteARQuery); q.setParameter("rsid", resultSet.getId()); resultsDone += q.executeUpdate(); AbstractDao.log .info("Deleted " + contrastsDone + " contrasts, " + resultsDone + " results. Flushing..."); session.flush(); session.clear(); } // Remove result set AbstractDao.log.info("Removing result set " + resultSet.getId()); super.remove(resultSet); this.getSessionFactory().getCurrentSession().flush(); }
From source file:ubic.gemma.persistence.service.analysis.expression.ExpressionExperimentSetDaoImpl.java
License:Apache License
@Override public void thaw(final ExpressionExperimentSet expressionExperimentSet) { this.getSessionFactory().getCurrentSession().buildLockRequest(LockOptions.NONE) .lock(expressionExperimentSet); Hibernate.initialize(expressionExperimentSet); Hibernate.initialize(expressionExperimentSet.getTaxon()); Hibernate.initialize(expressionExperimentSet.getExperiments()); }
From source file:ubic.gemma.persistence.service.expression.arrayDesign.ArrayDesignDaoImpl.java
License:Apache License
@Override public void removeBiologicalCharacteristics(final ArrayDesign arrayDesign) { if (arrayDesign == null) { throw new IllegalArgumentException("Array design cannot be null"); }/*from ww w . j a va 2 s. c o m*/ Session session = this.getSessionFactory().getCurrentSession(); session.buildLockRequest(LockOptions.NONE).lock(arrayDesign); int count = 0; for (CompositeSequence cs : arrayDesign.getCompositeSequences()) { cs.setBiologicalCharacteristic(null); session.update(cs); session.evict(cs); if (++count % ArrayDesignDaoImpl.LOGGING_UPDATE_EVENT_COUNT == 0) { AbstractDao.log.info("Cleared sequence association for " + count + " composite sequences"); } } }
From source file:ubic.gemma.persistence.service.expression.bioAssay.BioAssayDaoImpl.java
License:Apache License
@Override public void thaw(final BioAssay bioAssay) { try {//from w w w. ja va 2 s. c o m this.getSessionFactory().getCurrentSession().doWork(new Work() { @Override public void execute(Connection connection) { BioAssayDaoImpl.this.getSession().buildLockRequest(LockOptions.NONE).lock(bioAssay); Hibernate.initialize(bioAssay.getArrayDesignUsed()); Hibernate.initialize(bioAssay.getOriginalPlatform()); BioMaterial bm = bioAssay.getSampleUsed(); BioAssayDaoImpl.this.getSession().buildLockRequest(LockOptions.NONE).lock(bm); Hibernate.initialize(bm); Hibernate.initialize(bm.getBioAssaysUsedIn()); Hibernate.initialize(bm.getFactorValues()); BioAssayDaoImpl.this.getSession().evict(bm); BioAssayDaoImpl.this.getSession().evict(bioAssay); } }); } catch (Throwable th) { throw new RuntimeException( "Error performing 'BioAssayDao.thawRawAndProcessed(BioAssay bioAssay)' --> " + th, th); } }
From source file:ubic.gemma.persistence.service.expression.bioAssayData.BioAssayDimensionDaoImpl.java
License:Apache License
@Override public BioAssayDimension thawLite(final BioAssayDimension bioAssayDimension) { if (bioAssayDimension == null) return null; if (bioAssayDimension.getId() == null) return bioAssayDimension; this.getHibernateTemplate().execute(new org.springframework.orm.hibernate3.HibernateCallback<Object>() { @Override//from w w w . j av a 2 s. c o m public Object doInHibernate(org.hibernate.Session session) throws org.hibernate.HibernateException { session.buildLockRequest(LockOptions.NONE).lock(bioAssayDimension); Hibernate.initialize(bioAssayDimension); Hibernate.initialize(bioAssayDimension.getBioAssays()); return null; } }); return bioAssayDimension; }
From source file:ubic.gemma.persistence.service.expression.bioAssayData.BioAssayDimensionDaoImpl.java
License:Apache License
@Override public BioAssayDimension thaw(final BioAssayDimension bioAssayDimension) { if (bioAssayDimension == null) return null; if (bioAssayDimension.getId() == null) return bioAssayDimension; this.getHibernateTemplate().execute(new org.springframework.orm.hibernate3.HibernateCallback<Object>() { @Override/*from w w w .j av a2 s .com*/ public Object doInHibernate(org.hibernate.Session session) throws org.hibernate.HibernateException { session.buildLockRequest(LockOptions.NONE).lock(bioAssayDimension); Hibernate.initialize(bioAssayDimension); Hibernate.initialize(bioAssayDimension.getBioAssays()); for (BioAssay ba : bioAssayDimension.getBioAssays()) { if (ba != null) { session.buildLockRequest(LockOptions.NONE).lock(ba); Hibernate.initialize(ba); Hibernate.initialize(ba.getSampleUsed()); Hibernate.initialize(ba.getArrayDesignUsed()); Hibernate.initialize(ba.getOriginalPlatform()); BioMaterial bm = ba.getSampleUsed(); session.buildLockRequest(LockOptions.NONE).lock(bm); Hibernate.initialize(bm); Hibernate.initialize(bm.getBioAssaysUsedIn()); Hibernate.initialize(bm.getFactorValues()); } } return null; } }); return bioAssayDimension; }
From source file:ubic.gemma.persistence.service.expression.bioAssayData.DesignElementDataVectorDaoImpl.java
License:Apache License
@Override public void thawRawAndProcessed(Collection<DesignElementDataVector> designElementDataVectors) { if (designElementDataVectors == null) return;// www. j a v a2 s . com Session session = this.getSessionFactory().getCurrentSession(); Hibernate.initialize(designElementDataVectors); StopWatch timer = new StopWatch(); timer.start(); Collection<ExpressionExperiment> ees = new HashSet<>(); Map<BioAssayDimension, Collection<DesignElementDataVector>> dims = new HashMap<>(); Collection<CompositeSequence> cs = new HashSet<>(); for (DesignElementDataVector vector : designElementDataVectors) { session.buildLockRequest(LockOptions.NONE).lock(vector); Hibernate.initialize(vector); Hibernate.initialize(vector.getQuantitationType()); BioAssayDimension bad = vector.getBioAssayDimension(); if (!dims.containsKey(bad)) { dims.put(bad, new HashSet<DesignElementDataVector>()); } dims.get(bad).add(vector); cs.add(vector.getDesignElement()); ees.add(vector.getExpressionExperiment()); session.evict(vector.getQuantitationType()); session.evict(vector); } if (timer.getTime() > designElementDataVectors.size()) { AbstractDao.log.info("Thaw phase 1, " + designElementDataVectors.size() + " vectors initialized in " + timer.getTime() + "ms "); } timer.reset(); timer.start(); // lightly thaw the EEs we saw for (ExpressionExperiment ee : ees) { Hibernate.initialize(ee); session.evict(ee); } if (timer.getTime() > 200) { AbstractDao.log.info("Thaw phase 2, " + ees.size() + " vector-associated expression experiments in " + timer.getTime() + "ms "); } timer.reset(); timer.start(); // thaw the bioassayDimensions we saw -- usually one, more rarely two. for (BioAssayDimension bad : dims.keySet()) { BioAssayDimension tbad = (BioAssayDimension) this.getSessionFactory().getCurrentSession().createQuery( "select distinct bad from BioAssayDimension bad join fetch bad.bioAssays ba join fetch ba.sampleUsed " + "bm join fetch ba.arrayDesignUsed left join fetch bm.factorValues fetch all properties where bad.id= :bad ") .setParameter("bad", bad.getId()).uniqueResult(); assert tbad != null; assert !dims.get(tbad).isEmpty(); for (DesignElementDataVector v : designElementDataVectors) { if (v.getBioAssayDimension().getId().equals(tbad.getId())) { v.setBioAssayDimension(tbad); } } } if (timer.getTime() > 1000) { AbstractDao.log.info("Thaw phase 3, " + dims.size() + " vector-associated bioassaydimensions in " + timer.getTime() + "ms "); } timer.reset(); timer.start(); // thaw the designelements we saw. SLOW long lastTime = 0; int count = 0; for (CompositeSequence de : cs) { BioSequence seq = de.getBiologicalCharacteristic(); if (seq == null) continue; session.buildLockRequest(LockOptions.NONE).lock(seq); Hibernate.initialize(seq); // is this really necessary? ArrayDesign arrayDesign = de.getArrayDesign(); Hibernate.initialize(arrayDesign); if (++count % 10000 == 0) { if (timer.getTime() - lastTime > 1000) { AbstractDao.log .info("Thawed " + count + " vector-associated probes " + timer.getTime() + " ms"); } lastTime = timer.getTime(); } } timer.stop(); if (designElementDataVectors.size() >= 2000 || timer.getTime() > 200) { AbstractDao.log.info( "Thaw phase 4 " + cs.size() + " vector-associated probes thawed in " + timer.getTime() + "ms"); } }
From source file:ubic.gemma.persistence.service.expression.bioAssayData.DesignElementDataVectorDaoImpl.java
License:Apache License
@Override public void thaw(T designElementDataVector) { Session session = this.getHibernateTemplate().getSessionFactory().getCurrentSession(); BioSequence seq = designElementDataVector.getDesignElement().getBiologicalCharacteristic(); if (seq != null) { session.buildLockRequest(LockOptions.NONE).lock(seq); Hibernate.initialize(seq);// www .j a va 2s . co m } ArrayDesign arrayDesign = designElementDataVector.getDesignElement().getArrayDesign(); Hibernate.initialize(arrayDesign); // thaw the bioassays. for (BioAssay ba : designElementDataVector.getBioAssayDimension().getBioAssays()) { ba = (BioAssay) session.get(BioAssay.class, ba.getId()); Hibernate.initialize(ba.getArrayDesignUsed()); Hibernate.initialize(ba.getSampleUsed()); Hibernate.initialize(ba.getOriginalPlatform()); } }
From source file:ubic.gemma.persistence.service.expression.bioAssayData.ProcessedExpressionDataVectorDaoImpl.java
License:Apache License
/** * @param ee ee// w w w. j av a 2s .c o m * @param obs obs * @return Given an ExpressionExperimentSubset and vectors from the source experiment, give vectors that include * just the * data for the subset. */ private Collection<DoubleVectorValueObject> sliceSubSet(ExpressionExperimentSubSet ee, Collection<DoubleVectorValueObject> obs) { Collection<DoubleVectorValueObject> sliced = new HashSet<>(); if (obs == null || obs.isEmpty()) return sliced; this.getSessionFactory().getCurrentSession().buildLockRequest(LockOptions.NONE).lock(ee); Hibernate.initialize(ee.getBioAssays()); List<BioAssayValueObject> sliceBioAssays = new ArrayList<>(); DoubleVectorValueObject exemplar = obs.iterator().next(); BioAssayDimensionValueObject bad = new BioAssayDimensionValueObject(-1L); bad.setName("Subset of :" + exemplar.getBioAssayDimension().getName()); bad.setDescription("Subset slice"); bad.setSourceBioAssayDimension(exemplar.getBioAssayDimension()); bad.setIsSubset(true); Collection<Long> subsetBioAssayIds = EntityUtils.getIds(ee.getBioAssays()); for (BioAssayValueObject ba : exemplar.getBioAssays()) { if (!subsetBioAssayIds.contains(ba.getId())) { continue; } sliceBioAssays.add(ba); } bad.addBioAssays(sliceBioAssays); for (DoubleVectorValueObject vec : obs) { DoubleVectorValueObject s = new DoubleVectorValueObject(ee, vec, bad); sliced.add(s); } return sliced; }
From source file:ubic.gemma.persistence.service.expression.biomaterial.BioMaterialDaoImpl.java
License:Apache License
@Override public void thaw(final BioMaterial bioMaterial) { Session session = this.getSessionFactory().getCurrentSession(); session.buildLockRequest(LockOptions.NONE).lock(bioMaterial); Hibernate.initialize(bioMaterial);/*from w w w. ja v a 2 s .c o m*/ Hibernate.initialize(bioMaterial.getSourceTaxon()); Hibernate.initialize(bioMaterial.getBioAssaysUsedIn()); Hibernate.initialize(bioMaterial.getTreatments()); Hibernate.initialize(bioMaterial.getFactorValues()); }