List of usage examples for org.hibernate Query setReadOnly
Query<R> setReadOnly(boolean readOnly);
From source file:ubic.gemma.persistence.util.CommonQueries.java
License:Apache License
/** * @param session session/*from w w w . ja v a 2 s.co m*/ * @param eeId experiment id * @return list of array designs IDs used in given expression experiment */ @SuppressWarnings("unchecked") public static Collection<Long> getArrayDesignIdsUsed(Long eeId, Session session) { final String eeAdQuery = "select distinct ad.id from ExpressionExperiment as ee inner join " + "ee.bioAssays b inner join b.arrayDesignUsed ad where ee.id = :eeId"; org.hibernate.Query queryObject = session.createQuery(eeAdQuery); queryObject.setCacheable(true); queryObject.setParameter("eeId", eeId); queryObject.setReadOnly(true); queryObject.setFlushMode(FlushMode.MANUAL); List<?> list = queryObject.list(); return (Collection<Long>) list; }
From source file:ubic.gemma.persistence.util.CommonQueries.java
License:Apache License
/** * Given a gene, get all the composite sequences that map to it. * * @param session session//from ww w . ja v a 2s .c om * @param gene gene * @return composite sequences */ public static Collection<CompositeSequence> getCompositeSequences(Gene gene, Session session) { final String csQueryString = "select distinct cs from Gene as gene" + " join gene.products gp, BioSequence2GeneProduct ba, CompositeSequence cs " + " where ba.bioSequence.id=cs.biologicalCharacteristic.id and ba.geneProduct.id = gp.id and gene.id = :gene "; org.hibernate.Query queryObject = session.createQuery(csQueryString); queryObject.setParameter("gene", gene.getId(), LongType.INSTANCE); queryObject.setReadOnly(true); queryObject.setFlushMode(FlushMode.MANUAL); //noinspection unchecked return queryObject.list(); }
From source file:ubic.gemma.persistence.util.CommonQueries.java
License:Apache License
private static Query createGetADsUsedQueryObject(Long eeId, Session session) { final String eeAdQuery = "select distinct ad from ExpressionExperiment as ee inner join " + "ee.bioAssays b inner join b.arrayDesignUsed ad inner join ad.primaryTaxon fetch all properties where ee.id = :eeId"; Query queryObject = session.createQuery(eeAdQuery); queryObject.setCacheable(true);// w w w . j a v a 2 s . c o m queryObject.setParameter("eeId", eeId); queryObject.setReadOnly(true); queryObject.setFlushMode(FlushMode.MANUAL); return queryObject; }
From source file:ubic.gemma.persistence.util.CommonQueries.java
License:Apache License
public static Map<CompositeSequence, Collection<Gene>> getCs2GeneMap(Collection<Gene> genes, Collection<ArrayDesign> arrayDesigns, Session session) { StopWatch timer = new StopWatch(); timer.start();/*w ww . j av a 2 s . c o m*/ final String csQueryString = "select distinct cs, gene from Gene as gene" + " inner join gene.products gp, BioSequence2GeneProduct ba, CompositeSequence cs " + " where ba.bioSequence=cs.biologicalCharacteristic and ba.geneProduct = gp" + " and gene in (:genes) and cs.arrayDesign in (:ads) "; Map<CompositeSequence, Collection<Gene>> cs2gene = new HashMap<>(); Query queryObject = session.createQuery(csQueryString); queryObject.setCacheable(true); queryObject.setParameterList("genes", genes); queryObject.setParameterList("ads", arrayDesigns); queryObject.setReadOnly(true); queryObject.setFlushMode(FlushMode.MANUAL); ScrollableResults results = queryObject.scroll(ScrollMode.FORWARD_ONLY); CommonQueries.addGenes(cs2gene, results); results.close(); if (timer.getTime() > 200) { CommonQueries.log.info("Get cs2gene for " + genes.size() + " :" + timer.getTime() + "ms"); } return cs2gene; }
From source file:ubic.gemma.persistence.util.CommonQueries.java
License:Apache License
/** * @param genes genes//from ww w . ja v a 2s .c o m * @param session session * @return map of probes to input genes they map to. Other genes those probes might detect are not included. */ public static Map<CompositeSequence, Collection<Gene>> getCs2GeneMap(Collection<Gene> genes, Session session) { StopWatch timer = new StopWatch(); timer.start(); final String csQueryString = "select distinct cs, gene from Gene as gene" + " inner join gene.products gp, BioSequence2GeneProduct ba, CompositeSequence cs " + " where ba.bioSequence=cs.biologicalCharacteristic and ba.geneProduct = gp" + " and gene in (:genes) "; Map<CompositeSequence, Collection<Gene>> cs2gene = new HashMap<>(); org.hibernate.Query queryObject = session.createQuery(csQueryString); queryObject.setCacheable(true); queryObject.setParameterList("genes", genes); queryObject.setReadOnly(true); queryObject.setFlushMode(FlushMode.MANUAL); ScrollableResults results = queryObject.scroll(ScrollMode.FORWARD_ONLY); CommonQueries.addGenes(cs2gene, results); results.close(); if (timer.getTime() > 200) { CommonQueries.log.info("Get cs2gene for " + genes.size() + " :" + timer.getTime() + "ms"); } return cs2gene; }