List of usage examples for org.hibernate Session setCacheMode
void setCacheMode(CacheMode cacheMode);
From source file:com.sap.data.db.dao.EventDao.java
public String selectFuncName(String eventNumber) throws NotFoundException { List<EventPojo> list = null; Session session = null; try {//from w w w . java 2 s. co m session = HibernateUtil.getSession(); session.setCacheMode(CacheMode.GET); list = session.createCriteria("EventPojo").add(Restrictions.eq("EVENT_NUMBER", eventNumber)) .addOrder(Order.asc("EVENT_ID")).list(); } catch (HibernateException ex) { Logger.getLogger(EventDao.class.getName()).log(Level.SEVERE, null, ex); throw new NotFoundException(ex.getMessage()); } finally { HibernateUtil.close(session); } return list != null && !list.isEmpty() ? list.get(0).getFUNCNAME() : ""; }
From source file:com.sap.data.db.dao.EventDao.java
public List<EventPojo> selectEvents(String eventNumber) throws NotFoundException { List<EventPojo> evnts = null; Session session = null; try {// w w w .java 2s . c o m session = HibernateUtil.getSession(); session.setCacheMode(CacheMode.GET); evnts = session.createCriteria("EventPojo").add(Restrictions.eq("EVENT_NUMBER", eventNumber)) .addOrder(Order.asc("EVENT_ID")).list(); } catch (HibernateException ex) { Logger.getLogger(EventDao.class.getName()).log(Level.SEVERE, null, ex); throw new NotFoundException(ex.getMessage()); } finally { HibernateUtil.close(session); } return evnts; }
From source file:com.sap.data.db.dao.EventDao.java
public String selectEventNumber(String jCoFunction) throws NotFoundException { List<EventPojo> list = null; Session session = null; try {/* ww w . ja v a 2 s . co m*/ session = HibernateUtil.getSession(); session.setCacheMode(CacheMode.GET); list = session.createCriteria("EventPojo").add(Restrictions.eq("FUNCNAME", jCoFunction)).list(); } catch (HibernateException ex) { Logger.getLogger(EventDao.class.getName()).log(Level.SEVERE, null, ex); throw new NotFoundException(ex.getMessage()); } finally { HibernateUtil.close(session); } if (list != null && !list.isEmpty()) { return list.get(0).getEVENT_NUMBER(); } else { return null; } }
From source file:com.sap.data.db.dao.StructureDao.java
public List<?> selectE0015() throws NotFoundException { List<?> list = null;/*from w w w . j a v a 2 s . co m*/ Session session = null; try { session = HibernateUtil.getSession(); session.setCacheMode(CacheMode.GET); list = session.createCriteria(this.structure).list(); } catch (HibernateException ex) { Logger.getLogger(StructureDao.class.getName()).log(Level.SEVERE, null, ex); throw new NotFoundException(ex.getMessage()); } finally { HibernateUtil.close(session); } return list; }
From source file:com.sap.data.db.dao.StructureDao.java
public List<?> selectE0015(int firstResult, int maxResults) throws NotFoundException { List<?> list = null;//ww w. j av a 2 s. co m Session session = null; try { session = HibernateUtil.getSession(); session.setCacheMode(CacheMode.GET); list = session.createCriteria(this.structure).setFirstResult(firstResult).setMaxResults(maxResults) .list(); } catch (HibernateException ex) { Logger.getLogger(StructureDao.class.getName()).log(Level.SEVERE, null, ex); throw new NotFoundException(ex.getMessage()); } finally { HibernateUtil.close(session); } return list; }
From source file:com.sap.data.db.dao.StructureDao.java
public List<?> selectByJCO_USER(String jCo_USer, int firstResult, int maxResults) throws NotFoundException { List<?> list = null;/*from ww w .j av a2 s. c o m*/ Session session = null; try { session = HibernateUtil.getSession(); session.setCacheMode(CacheMode.GET); list = session.createCriteria(this.structure).add(Restrictions.eq("DId.JCO_USER", jCo_USer)) .setFirstResult(firstResult).setMaxResults(maxResults).list(); } catch (HibernateException ex) { Logger.getLogger(StructureDao.class.getName()).log(Level.SEVERE, null, ex); throw new NotFoundException(ex.getMessage()); } finally { HibernateUtil.close(session); } return list; }
From source file:com.sap.data.db.dao.StructureDao.java
public List<?> selectByJCO_USER(String jCo_USer) throws NotFoundException { List<?> list = null;// w ww . j a v a 2 s. c om Session session = null; try { session = HibernateUtil.getSession(); session.setCacheMode(CacheMode.GET); list = session.createCriteria(this.structure).add(Restrictions.eq("DId.JCO_USER", jCo_USer)).list(); } catch (HibernateException ex) { Logger.getLogger(StructureDao.class.getName()).log(Level.SEVERE, null, ex); throw new NotFoundException(ex.getMessage()); } finally { HibernateUtil.close(session); } return list; }
From source file:com.sap.data.db.dao.StructureDao.java
public int countSize() throws NotFoundException { int querySize = 0; Session session = null; try {/*from w ww.ja v a 2 s . co m*/ session = HibernateUtil.getSession(); session.setCacheMode(CacheMode.GET); Query query = session.createQuery("select count(o) from " + this.structure + " o"); querySize = ((Long) query.iterate().next()).intValue(); } catch (HibernateException | IllegalArgumentException ex) { Logger.getLogger(StructureDao.class.getName()).log(Level.SEVERE, null, ex); throw new NotFoundException(ex.getMessage()); } finally { HibernateUtil.close(session); } return querySize; }
From source file:de.fhdo.gui.admin.modules.terminology.Associations.java
License:Apache License
private void initList() { logger.debug("initList()"); // Header/*from ww w .jav a2 s . c o m*/ 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 {// ww w.j a va 2 s . 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(); }