List of usage examples for org.hibernate CacheMode IGNORE
CacheMode IGNORE
To view the source code for org.hibernate CacheMode IGNORE.
Click Source Link
From source file:com.ucieffe.index.WikipediaMassIndexer.java
License:Open Source License
public static void main(String[] args) { FullTextEntityManager ftEntityManager = new FullTextEntityManagerImpl( EntityManagerUtils.getEntityManagerInstance()); MassIndexerProgressMonitor monitor = new SimpleIndexingProgressMonitor(1500); MassIndexer massIndexer = ftEntityManager.createIndexer(Text.class); try {/*w ww. j a va2 s . com*/ massIndexer.purgeAllOnStart(true).optimizeAfterPurge(true).optimizeOnFinish(true) .batchSizeToLoadObjects(35).threadsForSubsequentFetching(3).threadsToLoadObjects(8) .threadsForIndexWriter(4).progressMonitor(monitor).cacheMode(CacheMode.IGNORE).startAndWait(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { System.out.println("Ended at: " + new Date()); } }
From source file:com.webbfontaine.valuewebb.cache.PersistenceUtil.java
License:Open Source License
/** * Calling this methods disables caching for current transaction/session. * * @param entityManager session's em//from w ww .j a va2 s.c o m */ public static void disableCaching(EntityManager entityManager) { ((HibernateSessionProxy) entityManager.getDelegate()).getSessionFactory().getCurrentSession() .setCacheMode(CacheMode.IGNORE); }
From source file:com.webbfontaine.valuewebb.model.util.TTUtils.java
License:Open Source License
/** * @return null if entity not found, true if TT is frozen, false otherwize *///from www.java2 s. c o m public static Boolean isTTFreezed(long id) { Query query = Utils.getEntityManager().createQuery("SELECT frozen FROM TtGen tt WHERE tt.id = :id"); query.setParameter("id", id); query.setHint("org.hibernate.cacheMode", CacheMode.IGNORE); return (Boolean) query.getSingleResult(); }
From source file:com.webbfontaine.valuewebb.model.util.Utils.java
License:Open Source License
public static Query setCacheBypass(Query query) { return query.setHint("org.hibernate.cacheMode", CacheMode.IGNORE); }
From source file:DAO.DAOCompra.java
public List<Compra> getProcesados() { Session session = em.unwrap(Session.class); return session.createCriteria(entityClass).setCacheMode(CacheMode.IGNORE) .add(Restrictions.eq("procesado", true)) .setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY).addOrder(Order.desc("pedido")) .list();// w w w . ja v a 2 s.co m }
From source file:de.fhdo.gui.admin.modules.terminology.Associations.java
License:Apache License
private void initList() { logger.debug("initList()"); // Header/*from w w w .java2 s .c om*/ List<GenericListHeaderType> header = new LinkedList<GenericListHeaderType>(); header.add(new GenericListHeaderType("ID", 90, "", true, "String", true, true, false, false)); header.add(new GenericListHeaderType("Name vorwrts", 250, "", true, "String", true, true, false, false)); header.add( new GenericListHeaderType("Name rckwrts", 250, "", true, "String", true, true, false, false)); header.add(new GenericListHeaderType("Codesystem", 350, "", true, "String", true, true, false, false)); //CacheManager.getInstance().clearAll(); //clearHibernateCache(); // Daten laden //SessionFactory sf = HibernateUtil.getSessionFactory(); SessionFactory sf = HibernateUtil.getNewSessionFactory(); //sf.evictQueries(); //sf.getCurrentSession().clear(); /*Cache cache = sf.getCache(); cache.evictEntityRegions(); cache.evictCollectionRegions(); cache.evictDefaultQueryRegion(); cache.evictQueryRegions(); //cache.evictNaturalIdRegions(); //cache.evictAllRegions(); cache.evictAllRegions(); // Evict data from all query regions.*/ Session hb_session = sf.openSession(); //hb_session.getTransaction().begin(); List<GenericListRowType> dataList = new LinkedList<GenericListRowType>(); try { String hql = "select distinct at from AssociationType at" + " join fetch at.codeSystemEntityVersion csev" + " join csev.codeSystemEntity cse" + " left join cse.codeSystemVersionEntityMemberships csvem"; //+ " left join fetch csvem.codeSystemVersion csv" //+ " left join fetch csv.codeSystem"; Query q = hb_session.createQuery(hql); q.setCacheable(false); q.setCacheMode(CacheMode.IGNORE); //q.setHint("toplink.refresh", "true"); hb_session.setCacheMode(CacheMode.IGNORE); hb_session.clear(); hb_session.flush(); List<de.fhdo.terminologie.db.hibernate.AssociationType> list = q.list(); logger.debug("Anzahl: " + list.size()); for (int i = 0; i < list.size(); ++i) { de.fhdo.terminologie.db.hibernate.AssociationType association = list.get(i); GenericListRowType row = createRowFromAssociation(association); dataList.add(row); } } catch (Exception e) { LoggingOutput.outputException(e, this); } finally { hb_session.close(); } // Liste initialisieren Include inc = (Include) getFellow("incList"); Window winGenericList = (Window) inc.getFellow("winGenericList"); genericList = (GenericList) winGenericList; genericList.setListActions(this); genericList.setButton_new(true); genericList.setButton_edit(true); genericList.setButton_delete(true); genericList.setListHeader(header); genericList.setDataList(dataList); }
From source file:de.fhdo.gui.admin.modules.terminology.Codesystems.java
License:Apache License
private void initList() { logger.debug("initList()"); try {/*from w ww . j a va 2s. c o m*/ West title = (West) getFellow("titleItem"); int selectedIndex = -1; // header information for list view List<GenericListHeaderType> header = new LinkedList<GenericListHeaderType>(); header.add(new GenericListHeaderType("ID", 60, "", true, "String", true, true, false, false)); header.add(new GenericListHeaderType(Labels.getLabel("name"), 0, "", true, "String", true, true, false, false)); // load data from db SessionFactory sf = HibernateUtil.getNewSessionFactory(); Session hb_session = sf.openSession(); //Session hb_session = HibernateUtil.getSessionFactory().openSession(); List<GenericListRowType> dataList = new LinkedList<GenericListRowType>(); try { if (mode == Mode.VALUESET) { ValueSet selectedVS = null; if (selectedItem instanceof ValueSet) selectedVS = (ValueSet) selectedItem; String hql = "from ValueSet order by name"; Query q = hb_session.createQuery(hql); q.setCacheable(false); q.setCacheMode(CacheMode.IGNORE); hb_session.setCacheMode(CacheMode.IGNORE); hb_session.clear(); hb_session.flush(); logger.debug("hql: " + hql); List<ValueSet> vsList = q.list(); for (int i = 0; i < vsList.size(); ++i) { ValueSet vs = vsList.get(i); GenericListRowType row = createRowFromValueSet(vs); dataList.add(row); if (selectedVS != null) { if (vs.getId().longValue() == selectedVS.getId()) selectedIndex = i; } } // set title title.setTitle(Labels.getLabel("valuesets")); } else { CodeSystem selectedCS = null; if (selectedItem instanceof CodeSystem) selectedCS = (CodeSystem) selectedItem; String hql = "from CodeSystem order by name"; Query q = hb_session.createQuery(hql); q.setCacheable(false); q.setCacheMode(CacheMode.IGNORE); hb_session.setCacheMode(CacheMode.IGNORE); hb_session.clear(); hb_session.flush(); logger.debug("hql: " + hql); List<CodeSystem> csList = q.list(); for (int i = 0; i < csList.size(); ++i) { CodeSystem cs = csList.get(i); GenericListRowType row = createRowFromCodesystem(cs); dataList.add(row); if (selectedCS != null) { if (cs.getId().longValue() == selectedCS.getId()) selectedIndex = i; } } // set title title.setTitle(Labels.getLabel("codesystems")); } } catch (Exception e) { LoggingOutput.outputException(e, this); } finally { hb_session.close(); } // initialize list Include inc = (Include) getFellow("incList"); Window winGenericList = (Window) inc.getFellow("winGenericList"); genericList = (GenericList) winGenericList; genericList.setListId("list"); genericList.setListActions(this); genericList.setButton_new(true); genericList.setButton_edit(false); genericList.setButton_delete(true); genericList.setListHeader(header); genericList.setDataList(dataList); if (selectedIndex >= 0) genericList.setSelectedIndex(selectedIndex); } catch (Exception ex) { LoggingOutput.outputException(ex, this); } initListVersion(); }
From source file:de.fhdo.gui.admin.modules.terminology.Codesystems.java
License:Apache License
private void initListVersion() { logger.debug("initListVersion()"); logger.debug("selectedItem: " + selectedItem); Include incVersions = (Include) getFellow("incListVersions"); West title = (West) getFellow("titleVersion"); if (selectedItem == null) { logger.debug("show empty message"); if (mode == Mode.VALUESET) title.setTitle(Labels.getLabel("valuesetVersion")); else//from w w w . j a v a 2s . c o m title.setTitle(Labels.getLabel("codesystemVersion")); incVersions.setSrc(null); incVersions.setSrc("/gui/templates/MessageInclude.zul?msg=" + Labels.getLabel("noSelection")); } else { logger.debug("show version list"); int selectedIndex = -1; incVersions.setSrc(null); incVersions.setSrc("/gui/templates/GenericList.zul"); try { // header information for list view List<GenericListHeaderType> header = new LinkedList<GenericListHeaderType>(); header.add(new GenericListHeaderType("ID", 60, "", true, "String", true, true, false, false)); header.add(new GenericListHeaderType(Labels.getLabel("name"), 0, "", true, "String", true, true, false, false)); header.add(new GenericListHeaderType(Labels.getLabel("status"), 80, "", true, "String", true, true, false, false)); // load data from db Session hb_session = HibernateUtil.getSessionFactory().openSession(); hb_session.setCacheMode(org.hibernate.CacheMode.IGNORE); hb_session.clear(); List<GenericListRowType> dataList = new LinkedList<GenericListRowType>(); try { if (mode == Mode.VALUESET) { // fill version list with value set versions ValueSet selectedVS = (ValueSet) selectedItem; ValueSetVersion selectedVSV = (ValueSetVersion) selectedItemVersion; String hql = "from ValueSetVersion where valueSetId=:vs_id order by name"; Query q = hb_session.createQuery(hql); q.setParameter("vs_id", selectedVS.getId()); q.setCacheable(false); q.setCacheMode(CacheMode.IGNORE); hb_session.setCacheMode(CacheMode.IGNORE); hb_session.clear(); hb_session.flush(); List<ValueSetVersion> vsList = q.list(); for (int i = 0; i < vsList.size(); ++i) { ValueSetVersion vsv = vsList.get(i); GenericListRowType row = createRowFromValueSetVersion(vsv); dataList.add(row); if (selectedVSV != null) { if (vsv.getVersionId().longValue() == selectedVSV.getVersionId()) selectedIndex = i; } } // set title title.setTitle(Labels.getLabel("valuesetVersion") + " - " + selectedVS.getName()); } else { // fill version list with code system versions CodeSystem selectedCS = (CodeSystem) selectedItem; CodeSystemVersion selectedCSV = (CodeSystemVersion) selectedItemVersion; String hql = "from CodeSystemVersion where codeSystemId=:cs_id order by name"; Query q = hb_session.createQuery(hql); q.setParameter("cs_id", selectedCS.getId()); q.setCacheable(false); q.setCacheMode(CacheMode.IGNORE); hb_session.setCacheMode(CacheMode.IGNORE); hb_session.clear(); hb_session.flush(); List<CodeSystemVersion> csList = q.list(); for (int i = 0; i < csList.size(); ++i) { CodeSystemVersion csv = csList.get(i); GenericListRowType row = createRowFromCodesystemVersion(csv); dataList.add(row); if (selectedCSV != null) { if (csv.getVersionId().longValue() == selectedCSV.getVersionId()) selectedIndex = i; } } // set title title.setTitle(Labels.getLabel("codesystemVersion") + " - " + selectedCS.getName()); } } catch (Exception e) { LoggingOutput.outputException(e, this); } finally { hb_session.close(); } // initialize list Window winGenericList = (Window) incVersions.getFellow("winGenericList"); genericListVersion = (GenericList) winGenericList; genericListVersion.setListId("listVersion"); genericListVersion.setListActions(this); genericListVersion.setButton_new(true); genericListVersion.setButton_edit(false); genericListVersion.setButton_delete(true); genericListVersion.setListHeader(header); genericListVersion.setDataList(dataList); if (selectedIndex >= 0) genericListVersion.setSelectedIndex(selectedIndex); Button button = new Button(Labels.getLabel("changeStatus") + "..."); button.addEventListener(Events.ON_CLICK, new EventListener<Event>() { public void onEvent(Event t) throws Exception { changeStatus(); } }); genericListVersion.removeCustomButtons(); genericListVersion.addCustomButton(button); } catch (Exception ex) { LoggingOutput.outputException(ex, this); } } initDetails(); }
From source file:de.iteratec.iteraplan.persistence.dao.SearchDAOImpl.java
License:Open Source License
/** {@inheritDoc} */ public void createIndexes(Set<Class<?>> classList) { Session session = this.getSession(); FullTextSession fullTextSession = getFullTextSession(); session.setFlushMode(FlushMode.MANUAL); // Disable flush operations session.setCacheMode(CacheMode.IGNORE); // Disable second-level cache operations int batchSize = 100; // data is read from the database for (Class<?> bbClass : classList) { ScrollableResults results = session.createCriteria(bbClass).setFetchSize(batchSize) .scroll(ScrollMode.SCROLL_INSENSITIVE); LOGGER.info("Indexing " + bbClass.getSimpleName()); int index = 0; while (results.next()) { index++;//from w w w. j a va2 s. com // entities are indexed fullTextSession.index(results.get(0)); if (index % batchSize == 0) { fullTextSession.flushToIndexes(); fullTextSession.clear(); } } results.close(); LOGGER.info("Index for " + bbClass.getSimpleName() + " was created!"); } }
From source file:edu.harvard.med.screensaver.db.ScreenResultsDAOImpl.java
License:Open Source License
public int createScreenedReagentCounts(final ScreenType screenType, Screen study, AnnotationType positiveAnnotationType, AnnotationType overallAnnotationType) { // Break this into two separate queries because of Hibernate bug (http://opensource.atlassian.com/projects/hibernate/browse/HHH-1615): // when using the "group by" clause with a full object (as opposed to an attribute of the object/table), // Hibernate is requiring that every attribute of the object be specified in a "group by" and not // just the object itself. so the workaround is to query once to get the id's then once again to // get the objects. log.info("1. get the reagent id's for the positive counts"); ScrollableResults sr = runScrollQuery(new edu.harvard.med.screensaver.db.ScrollQuery() { public ScrollableResults execute(Session session) { HqlBuilder builder = new HqlBuilder(); builder.select("r", "id").selectExpression("count(*)").from(AssayWell.class, "aw") .from("aw", AssayWell.libraryWell, "w", JoinType.INNER) .from("w", Well.latestReleasedReagent, "r", JoinType.INNER) .from("w", Well.library, "l", JoinType.INNER) .where("l", "screenType", Operator.EQUAL, screenType) .where("w", "libraryWellType", Operator.EQUAL, LibraryWellType.EXPERIMENTAL); builder.where("aw", "positive", Operator.EQUAL, Boolean.TRUE); builder.groupBy("r", "id"); log.debug("hql: " + builder.toHql()); return builder.toQuery(session, true).setCacheMode(CacheMode.IGNORE) .scroll(ScrollMode.FORWARD_ONLY); }/*w w w.ja va 2 s . c o m*/ }); Map<Integer, Long> positivesMap = Maps.newHashMap(); while (sr.next()) { Object[] row = sr.get(); positivesMap.put((Integer) row[0], (Long) row[1]); } log.info("2. get the reagent id's for the overall counts"); sr = runScrollQuery(new edu.harvard.med.screensaver.db.ScrollQuery() { public ScrollableResults execute(Session session) { HqlBuilder builder = new HqlBuilder(); builder.select("r", "id").selectExpression("count(*)").from(AssayWell.class, "aw") .from("aw", AssayWell.libraryWell, "w", JoinType.INNER) .from("w", Well.library, "l", JoinType.INNER) .from("w", Well.latestReleasedReagent, "r", JoinType.INNER) .where("l", "screenType", Operator.EQUAL, screenType) .where("w", "libraryWellType", Operator.EQUAL, LibraryWellType.EXPERIMENTAL) .groupBy("r", "id"); log.debug("hql: " + builder.toHql()); return builder.toQuery(session, true).setCacheMode(CacheMode.IGNORE) .scroll(ScrollMode.FORWARD_ONLY); } }); Map<Integer, Long> overallMap = Maps.newHashMap(); while (sr.next()) { Object[] row = sr.get(); overallMap.put((Integer) row[0], (Long) row[1]); } log.info("3. get the Reagents"); sr = runScrollQuery(new edu.harvard.med.screensaver.db.ScrollQuery() { public ScrollableResults execute(Session session) { HqlBuilder builder = new HqlBuilder(); builder.select("r").distinctProjectionValues().from(AssayWell.class, "aw") .from("aw", AssayWell.libraryWell, "w", JoinType.INNER) .from("w", Well.library, "l", JoinType.INNER) .from("w", Well.latestReleasedReagent, "r", JoinType.INNER) .where("l", "screenType", Operator.EQUAL, screenType) .where("w", "libraryWellType", Operator.EQUAL, LibraryWellType.EXPERIMENTAL); log.debug("hql: " + builder.toHql()); return builder.toQuery(session, true).setCacheMode(CacheMode.IGNORE) .scroll(ScrollMode.FORWARD_ONLY); } }); log.info("4. build the Study: positives: " + positivesMap.size() + ", reagents: " + overallMap.size()); int count = 0; while (sr.next()) { Reagent r = (Reagent) sr.get()[0]; AnnotationValue av = new AnnotationValue(overallAnnotationType, r, null, (double) overallMap.get(r.getReagentId()).intValue()); _dao.saveOrUpdateEntity(av); Long positiveCount = positivesMap.get(r.getReagentId()); if (positiveCount != null) { av = new AnnotationValue(positiveAnnotationType, r, null, (double) positiveCount.intValue()); _dao.saveOrUpdateEntity(av); } // Note: due to memory performance, we will build the study_reagent_link later if (count++ % ROWS_TO_CACHE == 0) { log.debug("flushing"); _dao.flush(); _dao.clear(); } if (count % 10000 == 0) { log.info("" + count + " reagents processed"); } } log.info("save the study"); _dao.saveOrUpdateEntity(study); _dao.flush(); log.info("populateStudyReagentLinkTable"); int reagentCount = populateStudyReagentLinkTable(study.getScreenId()); log.info("done: positives: " + positivesMap.size() + ", reagents: " + overallMap.size()); return reagentCount; }