List of usage examples for org.hibernate Query setCacheable
Query<R> setCacheable(boolean cacheable);
From source file:com.quix.aia.cn.imo.mapper.InterviewMaintenance.java
License:Open Source License
/** * <p>Method is used to get all Deleted Interview for Rest service</p> * @return ArrayList of Interview// w ww. j a va 2 s. c o m */ public ArrayList getAllDeletedInterviewRest() { // TODO Auto-generated method stub log.log(Level.SEVERE, "InteriewMaintenance --> getAllDeletedInterviewRest "); Session session = null; ArrayList interviewList = new ArrayList(); try { session = HibernateFactory.openSession(); Date sdate = new Date(); log.log(Level.SEVERE, "Start Time " + sdate.getTime()); Query query = session.createQuery("SELECT interview_code FROM Interview where status = 0 "); interviewList = (ArrayList<Interview>) query.setCacheable(true).list(); Date edate = new Date(); log.log(Level.SEVERE, "Total Time " + (edate.getTime() - sdate.getTime())); } catch (Exception e) { log.log(Level.SEVERE, e.getMessage()); e.printStackTrace(); LogsMaintenance logsMain = new LogsMaintenance(); StringWriter errors = new StringWriter(); e.printStackTrace(new PrintWriter(errors)); logsMain.insertLogs("InterViewMaintenance", Level.SEVERE + "", errors.toString()); } finally { try { HibernateFactory.close(session); } catch (Exception e) { log.log(Level.SEVERE, e.getMessage()); e.printStackTrace(); } } return interviewList; }
From source file:com.quix.aia.cn.imo.mapper.InterviewMaintenance.java
License:Open Source License
/** * <p>Method is used to get all Interview for Rest service</p> * @return ArrayList of Interview//from w w w. j a va 2s. c o m */ public ArrayList getAllInterviewRestPast(String agentId, String candidateCode) { // TODO Auto-generated method stub log.log(Level.SEVERE, "InteriewMaintenance --> getAllInterviewRestPast "); Session session = null; ArrayList interviewList = new ArrayList(); try { session = HibernateFactory.openSession(); Date sdate = new Date(); log.log(Level.SEVERE, "Start Time " + sdate.getTime()); Date now = new Date(); Query query = session .createQuery("select distinct i FROM Interview i,InterviewCandidate ic where i.status = 1 " + " AND (i.interviewDate < :interviewDate OR ( i.interviewDate = :interviewDate AND i.StartTime <= :startTime ))" + " AND ic.status = 1 AND ic.interviewCode=i.interview_code AND ic.interviewCandidateCode = :candidateCode "); System.out.println("" + now); System.out.println("" + LMSUtil.HH_MM_SS.parse(LMSUtil.HH_MM_SS.format(now))); query.setParameter("startTime", LMSUtil.HH_MM_SS.parse(LMSUtil.HH_MM_SS.format(now))); query.setParameter("interviewDate", sdf1.parse(sdf1.format(now))); query.setParameter("candidateCode", candidateCode); interviewList = (ArrayList<Event>) query.setCacheable(true).list(); Date edate = new Date(); log.log(Level.SEVERE, "Total Time " + (edate.getTime() - sdate.getTime())); } catch (Exception e) { log.log(Level.SEVERE, e.getMessage()); e.printStackTrace(); LogsMaintenance logsMain = new LogsMaintenance(); StringWriter errors = new StringWriter(); e.printStackTrace(new PrintWriter(errors)); logsMain.insertLogs("InterViewMaintenance", Level.SEVERE + "", errors.toString()); } finally { try { HibernateFactory.close(session); } catch (Exception e) { log.log(Level.SEVERE, e.getMessage()); e.printStackTrace(); } } return interviewList; }
From source file:com.quix.aia.cn.imo.mapper.InterviewMaintenance.java
License:Open Source License
/** * <p>This method for use cache data for interview </p> * @param sscCode//w w w.j a v a2s.c o m * @return ArrayList */ public ArrayList getInterviewRest(int sscCode) { // TODO Auto-generated method stub log.log(Level.INFO, "InteriewMaintenance --> getInterviewRest "); Session session = null; ArrayList interviewList = new ArrayList(); ArrayList<Interview> list = new ArrayList<Interview>(); ArrayList<Bu> bulist = new ArrayList<Bu>(); ArrayList<District> distlist = new ArrayList<District>(); ArrayList<City> citylist = new ArrayList<City>(); ArrayList<Ssc> ssclist = new ArrayList<Ssc>(); try { session = HibernateFactory.openSession(); Date sdate = new Date(); log.log(Level.SEVERE, "Start Time " + sdate.getTime()); Query query = session.createQuery("FROM Ssc where status = 1 AND sscCode=:ssccode "); query.setParameter("ssccode", sscCode); ssclist = (ArrayList<Ssc>) query.setCacheable(true).list(); Ssc ssc = ssclist.get(0); query = session.createQuery("FROM City where status = 1 and cityCode=:citycode "); query.setParameter("citycode", ssc.getCityCode()); citylist = (ArrayList<City>) query.setCacheable(true).list(); City city = citylist.get(0); query = session.createQuery("FROM District where status = 1 and districtCode=:distcode "); query.setParameter("distcode", city.getBranchCode()); distlist = (ArrayList<District>) query.setCacheable(true).list(); District dist = distlist.get(0); query = session.createQuery("FROM Bu where status = 1 and buCode=:bucode "); query.setParameter("bucode", dist.getBuCode()); bulist = (ArrayList<Bu>) query.setCacheable(true).list(); Bu bu = bulist.get(0); query = session.createQuery("FROM Interview where status = 1 and buCode=:bucode and district=0 "); query.setParameter("bucode", bu.getBuCode()); list = (ArrayList<Interview>) query.setCacheable(true).list(); interviewList.addAll(list); query = session.createQuery("FROM Interview where status = 1 and district=:distcode and cityCode=0 "); query.setParameter("distcode", dist.getDistrictCode()); list = (ArrayList<Interview>) query.setCacheable(true).list(); interviewList.addAll(list); query = session.createQuery("FROM Interview where status = 1 and cityCode=:citycode and sscCode=0 "); query.setParameter("citycode", city.getCityCode()); list = (ArrayList<Interview>) query.setCacheable(true).list(); interviewList.addAll(list); query = session.createQuery("FROM Interview where status = 1 and sscCode=:ssccode "); query.setParameter("ssccode", sscCode); list = (ArrayList<Interview>) query.setCacheable(true).list(); interviewList.addAll(list); Date edate = new Date(); log.log(Level.SEVERE, "Total Time " + (edate.getTime() - sdate.getTime())); } catch (Exception e) { log.log(Level.SEVERE, e.getMessage()); e.printStackTrace(); LogsMaintenance logsMain = new LogsMaintenance(); StringWriter errors = new StringWriter(); e.printStackTrace(new PrintWriter(errors)); logsMain.insertLogs("InterViewMaintenance", Level.SEVERE + "", errors.toString()); } finally { try { HibernateFactory.close(session); } catch (Exception e) { log.log(Level.SEVERE, e.getMessage()); e.printStackTrace(); } } return interviewList; }
From source file:com.quix.aia.cn.imo.mapper.PresenterMaintenance.java
License:Open Source License
/** * <p>Method is used to get all Presenter for Rest service</p> * @return ArrayList of Presenter/* w w w. java2 s. co m*/ */ public ArrayList getAllPresenterRest(AamData aamData, String agentId) { // TODO Auto-generated method stub log.log(Level.SEVERE, "PresenterMaintenance --> getAllPresenterRest "); Session session = null; ArrayList presenterList = new ArrayList(); ArrayList<Presenter> list = new ArrayList<Presenter>(); ArrayList<Bu> bulist = new ArrayList<Bu>(); ArrayList<District> distlist = new ArrayList<District>(); ArrayList<City> citylist = new ArrayList<City>(); ArrayList<Ssc> ssclist = new ArrayList<Ssc>(); try { session = HibernateFactory.openSession(); Date sdate = new Date(); log.log(Level.SEVERE, "Start Time " + sdate.getTime()); // Criteria crit = session.createCriteria(Ssc.class); // crit.add(Restrictions.eq("sscName", aamData.getSsc())); // crit.add(Restrictions.eq("status", true)); // ssclist=(ArrayList<Ssc>) crit.list(); // Ssc ssc=ssclist.get(0); // // Query query=session.createQuery("FROM City where status = 1 and cityCode=:citycode "); // query.setParameter("citycode", ssc.getCityCode()); // citylist=(ArrayList<City>) query.setCacheable(true).list(); // City city=citylist.get(0); // // query=session.createQuery("FROM District where status = 1 and districtCode=:distcode "); // query.setParameter("distcode", city.getBranchCode()); // distlist=(ArrayList<District>) query.setCacheable(true).list(); // District dist=distlist.get(0); // // query = session.createQuery("FROM Bu where status = 1 and buCode=:bucode "); // query.setParameter("bucode", dist.getBuCode()); // bulist=(ArrayList<Bu>) query.setCacheable(true).list(); // Bu bu=bulist.get(0); // Query query=session.createQuery("FROM Presenter where status = 1 and buCode=:bucode and district=0 "); // query.setParameter("bucode",aamData.getBuCode()); // list=(ArrayList<Presenter>) query.setCacheable(true).list(); // presenterList.addAll(list); // // query=session.createQuery("FROM Presenter where status = 1 and district=:distcode and branchCode=0 "); // query.setParameter("distcode",aamData.getDistrictCode()); // list=(ArrayList<Presenter>) query.setCacheable(true).list(); // presenterList.addAll(list); // // // query=session.createQuery("FROM Presenter where status = 1 and branchCode=:branchCode and cityCode=0 "); // query.setParameter("branchCode",aamData.getBranchCode()); // list=(ArrayList<Presenter>) query.setCacheable(true).list(); // presenterList.addAll(list); // // // query=session.createQuery("FROM Presenter where status = 1 and cityCode=:citycode and sscCode=0 "); // query.setParameter("citycode", aamData.getCityCode()); // list=(ArrayList<Presenter>) query.setCacheable(true).list(); // presenterList.addAll(list); // // // query=session.createQuery("FROM Presenter where status = 1 and sscCode=:ssccode "); // query.setParameter("ssccode", aamData.getSscCode()); // list=(ArrayList<Presenter>) query.setCacheable(true).list(); // presenterList.addAll(list); Query query = session.createQuery("FROM Presenter where status = 1 and " + "( (buCode=:bucode and district=0) " + "or (district=:distcode and branchCode=0)" + "or (branchCode=:branchCode and cityCode='0')" + "or (cityCode=:citycode and sscCode='0')" + "or (sscCode=:ssccode and officeCode = '0')" + "or (officeCode =:officeCode ) )"); query.setParameter("bucode", aamData.getBuCode()); query.setParameter("distcode", aamData.getDistrictCode()); query.setParameter("branchCode", aamData.getBranchCode()); query.setParameter("citycode", aamData.getCity()); query.setParameter("ssccode", aamData.getSsc()); query.setParameter("officeCode", aamData.getOfficeCode()); list = (ArrayList<Presenter>) query.setCacheable(true).list(); presenterList.addAll(list); Date edate = new Date(); log.log(Level.SEVERE, "Total Time " + (edate.getTime() - sdate.getTime())); } catch (Exception e) { log.log(Level.SEVERE, e.getMessage()); e.printStackTrace(); } finally { try { HibernateFactory.close(session); } catch (Exception e) { log.log(Level.SEVERE, e.getMessage()); e.printStackTrace(); } } return presenterList; }
From source file:com.quix.aia.cn.imo.utilities.ImoUtilityData.java
License:Open Source License
public ArrayList<Department> getAllDepartment() { // TODO Auto-generated method stub log.log(Level.INFO, "ImoUtilitiData --> getAllDepartment"); ArrayList<Department> arrActivity = new ArrayList<Department>(); Session session = null;//from w ww . j a va 2s . c om try { session = HibernateFactory.openSession(); Query query = session.createQuery(" from Department where status = 1 ORDER BY orderCode,deptName"); arrActivity = (ArrayList<Department>) query.setCacheable(true).list(); } catch (Exception e) { log.log(Level.SEVERE, e.getMessage()); e.printStackTrace(); LogsMaintenance logsMain = new LogsMaintenance(); StringWriter errors = new StringWriter(); e.printStackTrace(new PrintWriter(errors)); logsMain.insertLogs("IMOUtilityData", Level.SEVERE + "", errors.toString()); } finally { HibernateFactory.close(session); } return arrActivity; }
From source file:com.quix.aia.cn.imo.utilities.ImoUtilityData.java
License:Open Source License
public void getRefresh() { log.log(Level.INFO, "ImoUtilityDate --> getRefresh"); Session session = null;/*from w w w. ja v a2 s. co m*/ Transaction tx; List<Holiday> listHoliday = null; List<E_Greeting> listEGreeting = null; List<Interview> listInterview = null; List<Presenter> listPresenter = null; List<Announcement> listAnnouncement = null; List<Event> listEvent = null; List<Bu> listbu = null; List<District> listdist = null; List<Branch> listbranch = null; List<City> listcity = null; List<Ssc> listSsc = null; List<Office> listOffice = null; ArrayList al = new ArrayList(); try { Query query = null; session = HibernateFactory.openSession(); Date sdate = new Date(); log.log(Level.INFO, "Start Time " + sdate.getTime()); listbu = session.createQuery("FROM Bu where status = 1").setCacheable(true).list(); listdist = session.createQuery("FROM District where status = 1").setCacheable(true).list(); listbranch = session.createQuery("FROM Branch where status = 1").setCacheable(true).list(); listcity = session.createQuery("FROM City where status = 1").setCacheable(true).list(); listSsc = session.createQuery("FROM Ssc where status = 1").setCacheable(true).list(); listOffice = session.createQuery("FROM Office where status = 1").setCacheable(true).list(); listbu = session.createQuery("FROM Bu where status = 1 order by buName").setCacheable(true).list(); listdist = session.createQuery("FROM District where status = 1 order by districtName") .setCacheable(true).list(); listbranch = session.createQuery("FROM Branch where status = 1 order by branchName").setCacheable(true) .list(); listcity = session.createQuery("FROM City where status = 1 order by cityName").setCacheable(true) .list(); listSsc = session.createQuery("FROM Ssc where status = 1 order by sscName").setCacheable(true).list(); listOffice = session.createQuery("FROM Office where status = 1 order by sscName").setCacheable(true) .list(); for (int i = 0; i < listbu.size(); i++) { Bu bu = listbu.get(i); // query= session.createQuery("FROM Holiday where status = 1 and buCode=:bucode and district=0 "); // query.setParameter("bucode", bu.getBuCode()); // listHoliday=query.setCacheable(true).list(); query = session.createQuery("FROM Interview where status = 1 and buCode=:bucode and district=0 "); query.setParameter("bucode", bu.getBuCode()); listInterview = query.setCacheable(true).list(); // listHoliday = session.createQuery("FROM Holiday where status = 1 and buCode="+ bu.getBuCode()+" and district=0 ").setFirstResult(0).setCacheable(true).list(); // al.add(listHoliday); listInterview = session .createQuery( "FROM Interview where status = 1 and buCode=" + bu.getBuCode() + " and district=0 ") .setFirstResult(0).setCacheable(true).list(); listPresenter = session .createQuery( "FROM Presenter where status = 1 and buCode=" + bu.getBuCode() + " and district=0 ") .setFirstResult(0).setCacheable(true).list(); listAnnouncement = session.createQuery( "FROM Announcement where status = 1 and buCode=" + bu.getBuCode() + " and district=0 ") .setFirstResult(0).setCacheable(true).list(); listEvent = session .createQuery( "FROM Event where status = 1 and buCode=" + bu.getBuCode() + " and district=0 ") .setFirstResult(0).setCacheable(true).list(); query = session.createQuery("FROM Presenter where status = 1 and buCode=:bucode and district=0 "); query.setParameter("bucode", bu.getBuCode()); listPresenter = query.setCacheable(true).list(); query = session .createQuery("FROM Announcement where status = 1 and buCode=:bucode and district=0 "); query.setParameter("bucode", bu.getBuCode()); listAnnouncement = query.setCacheable(true).list(); query = session.createQuery("FROM Event where status = 1 and buCode=:bucode and district=0 "); query.setParameter("bucode", bu.getBuCode()); listEvent = query.setCacheable(true).list(); query = session.createQuery("FROM Bu where status = 1 and buCode=:bucode "); query.setParameter("bucode", bu.getBuCode()); ArrayList<Bu> bulist = (ArrayList<Bu>) query.setCacheable(true).list(); for (int j = 0; j < listdist.size(); j++) { District dist = listdist.get(j); // query= session.createQuery("FROM Holiday where status = 1 and district=:distcode and branchCode=0 "); // query.setParameter("distcode", dist.getDistrictCode()); // listHoliday=query.setCacheable(true).list(); query = session.createQuery( "FROM Interview where status = 1 and district=:distcode and branchCode=0 "); query.setParameter("distcode", dist.getDistrictCode()); listInterview = query.setCacheable(true).list(); query = session.createQuery( "FROM Presenter where status = 1 and district=:distcode and branchCode=0 "); query.setParameter("distcode", dist.getDistrictCode()); listPresenter = query.setCacheable(true).list(); query = session.createQuery( "FROM Announcement where status = 1 and district=:distcode and branchCode=0 "); query.setParameter("distcode", dist.getDistrictCode()); listAnnouncement = query.setCacheable(true).list(); query = session .createQuery("FROM Event where status = 1 and district=:distcode and branchCode=0 "); query.setParameter("distcode", dist.getDistrictCode()); listEvent = query.setCacheable(true).list(); query = session.createQuery("FROM District where status = 1 and districtCode=:distcode "); query.setParameter("distcode", dist.getDistrictCode()); ArrayList<District> distlist = (ArrayList<District>) query.setCacheable(true).list(); for (int a = 0; a < listbranch.size(); a++) { Branch branch = listbranch.get(a); // query= session.createQuery("FROM Holiday where status = 1 and branchCode=:branch and cityCode=0 "); // query.setParameter("branch", branch.getBranchCode()); // listHoliday=query.setCacheable(true).list(); query = session.createQuery( "FROM Interview where status = 1 and branchCode=:branch and cityCode=0 "); query.setParameter("branch", branch.getBranchCode()); listInterview = query.setCacheable(true).list(); query = session.createQuery( "FROM Presenter where status = 1 and branchCode=:branch and cityCode=0 "); query.setParameter("branch", branch.getBranchCode()); listPresenter = query.setCacheable(true).list(); query = session.createQuery( "FROM Announcement where status = 1 and branchCode=:branch and cityCode=0 "); query.setParameter("branch", branch.getBranchCode()); listAnnouncement = query.setCacheable(true).list(); query = session .createQuery("FROM Event where status = 1 and branchCode=:branch and cityCode=0 "); query.setParameter("branch", branch.getBranchCode()); listEvent = query.setCacheable(true).list(); query = session.createQuery("FROM Branch where status = 1 and branchCode=:branch "); query.setParameter("branch", branch.getBranchCode()); for (int k = 0; k < listcity.size(); k++) { City city = listcity.get(k); // query= session.createQuery("FROM Holiday where status = 1 and cityCode=:citycode and sscCode=0 "); // query.setParameter("citycode", city.getCityCode()); // listHoliday=query.setCacheable(true).list(); query = session.createQuery( "FROM Interview where status = 1 and cityCode=:citycode and sscCode=0 "); query.setParameter("citycode", city.getCityCode()); listInterview = query.setCacheable(true).list(); query = session.createQuery( "FROM Presenter where status = 1 and cityCode=:citycode and sscCode=0 "); query.setParameter("citycode", city.getCityCode()); listPresenter = query.setCacheable(true).list(); query = session.createQuery( "FROM Announcement where status = 1 and cityCode=:citycode and sscCode=0 "); query.setParameter("citycode", city.getCityCode()); listAnnouncement = query.setCacheable(true).list(); query = session.createQuery( "FROM Event where status = 1 and cityCode=:citycode and sscCode=0 "); query.setParameter("citycode", city.getCityCode()); listEvent = query.setCacheable(true).list(); query = session.createQuery("FROM City where status = 1 and cityCode=:citycode "); query.setParameter("citycode", city.getCityCode()); ArrayList<City> citylist = (ArrayList<City>) query.setCacheable(true).list(); for (int l = 0; l < listSsc.size(); l++) { Ssc ssc = listSsc.get(l); // query= session.createQuery("FROM Holiday where status = 1 and sscCode=:ssccode "); // query.setParameter("ssccode", ssc.getSscCode()); // listHoliday=query.setCacheable(true).list(); // query = session .createQuery("FROM Interview where status = 1 and sscCode=:ssccode "); query.setParameter("ssccode", ssc.getSscCode()); listInterview = query.setCacheable(true).list(); query = session .createQuery("FROM Presenter where status = 1 and sscCode=:ssccode "); query.setParameter("ssccode", ssc.getSscCode()); listPresenter = query.setCacheable(true).list(); query = session .createQuery("FROM Announcement where status = 1 and sscCode=:ssccode "); query.setParameter("ssccode", ssc.getSscCode()); listAnnouncement = query.setCacheable(true).list(); query = session.createQuery("FROM Event where status = 1 and sscCode=:ssccode "); query.setParameter("ssccode", ssc.getSscCode()); listEvent = query.setCacheable(true).list(); query = session.createQuery("FROM Ssc where status = 1 and sscCode=:ssccode"); query.setParameter("ssccode", ssc.getSscCode()); ArrayList<Ssc> ssclist = (ArrayList<Ssc>) query.setCacheable(true).list(); for (int m = 0; m < listOffice.size(); m++) { Office office = listOffice.get(m); // query= session.createQuery("FROM Holiday where status = 1 and officeCode=:code "); // query.setParameter("ssccode", ssc.getSscCode()); // listHoliday=query.setCacheable(true).list(); query = session.createQuery( "FROM Interview where status = 1 and officeCode=:code "); query.setParameter("code", office.getOfficeCode()); listInterview = query.setCacheable(true).list(); query = session .createQuery("FROM Presenter where status = 1 and officeCode=:code "); query.setParameter("code", office.getOfficeCode()); listPresenter = query.setCacheable(true).list(); query = session.createQuery( "FROM Announcement where status = 1 and officeCode=:code "); query.setParameter("code", office.getOfficeCode()); listAnnouncement = query.setCacheable(true).list(); query = session .createQuery("FROM Event where status = 1 and officeCode=:code "); query.setParameter("code", office.getOfficeCode()); listEvent = query.setCacheable(true).list(); query = session .createQuery("FROM Office where status = 1 and officeCode=:code"); query.setParameter("code", office.getOfficeCode()); ArrayList<Office> officelist = (ArrayList<Office>) query.setCacheable(true) .list(); } // close Office for loop } // close ssc for loop } //close city for loop } // branch for loop } //close district for loop } //close bu for loop listEGreeting = session.createQuery("FROM E_Greeting where status = 1").setCacheable(true).list(); Date edate = new Date(); log.log(Level.INFO, "Total Time " + (edate.getTime() - sdate.getTime())); session.flush(); session.clear(); session.close(); } catch (Exception e) { log.log(Level.INFO, "ImoUtilityDate --> getRefresh --> Exception " + e); e.printStackTrace(); LogsMaintenance logsMain = new LogsMaintenance(); StringWriter errors = new StringWriter(); e.printStackTrace(new PrintWriter(errors)); logsMain.insertLogs("IMOUtilityData", Level.SEVERE + "", errors.toString()); } finally { try { HibernateFactory.close(session); } catch (Exception e) { e.printStackTrace(); } } }
From source file:com.quix.aia.cn.imo.utilities.ImoUtilityData.java
License:Open Source License
public void getEventCache() { log.log(Level.INFO, "ImoUtilityDate --> getEventCache"); Session session = null;// w ww . j a v a 2s. co m Transaction tx; List<Event> listEvent = null; List<Bu> listbu = null; List<District> listdist = null; List<Branch> listbranch = null; List<City> listcity = null; List<Ssc> listSsc = null; ArrayList al = new ArrayList(); try { Query query = null; session = HibernateFactory.openSession(); Date sdate = new Date(); log.log(Level.INFO, "Start Time " + sdate.getTime()); listbu = session.createQuery("FROM Bu where status = 1").setCacheable(true).list(); listdist = session.createQuery("FROM District where status = 1").setCacheable(true).list(); listbranch = session.createQuery("FROM Branch where status = 1").setCacheable(true).list(); listcity = session.createQuery("FROM City ").setCacheable(true).list(); listSsc = session.createQuery("FROM Ssc ").setCacheable(true).list(); listbu = session.createQuery("FROM Bu where status = 1 order by buName").setCacheable(true).list(); listdist = session.createQuery("FROM District where status = 1 order by districtName") .setCacheable(true).list(); listbranch = session.createQuery("FROM Branch where status = 1 order by branchName").setCacheable(true) .list(); listcity = session.createQuery("FROM City order by cityName").setCacheable(true).list(); listSsc = session.createQuery("FROM Ssc order by sscName").setCacheable(true).list(); for (int i = 0; i < listbu.size(); i++) { Bu bu = listbu.get(i); query = session.createQuery("FROM Event where status = 1 and buCode=:bucode and district=0 "); query.setParameter("bucode", bu.getBuCode()); listEvent = query.setCacheable(true).list(); query = session.createQuery("FROM Bu where status = 1 and buCode=:bucode "); query.setParameter("bucode", bu.getBuCode()); ArrayList<Bu> bulist = (ArrayList<Bu>) query.setCacheable(true).list(); for (int j = 0; j < listdist.size(); j++) { District dist = listdist.get(j); query = session .createQuery("FROM Event where status = 1 and district=:distcode and branchCode=0 "); query.setParameter("distcode", dist.getDistrictCode()); listEvent = query.setCacheable(true).list(); query = session.createQuery("FROM District where status = 1 and districtCode=:distcode "); query.setParameter("distcode", dist.getDistrictCode()); ArrayList<District> distlist = (ArrayList<District>) query.setCacheable(true).list(); for (int a = 0; a < listbranch.size(); a++) { Branch branch = listbranch.get(a); query = session.createQuery( "FROM Event where status = 1 and branchCode=:branch and cityCode=:code "); query.setParameter("branch", branch.getBranchCode()); query.setParameter("code", "0"); listEvent = query.setCacheable(true).list(); query = session.createQuery("FROM Branch where status = 1 and branchCode=:branch "); query.setParameter("branch", branch.getBranchCode()); ArrayList<Branch> branchlist = (ArrayList<Branch>) query.setCacheable(true).list(); for (int k = 0; k < listcity.size(); k++) { City city = listcity.get(k); query = session.createQuery( "FROM Event where status = 1 and cityCode=:citycode and sscCode=:code "); query.setParameter("citycode", city.getCityName()); query.setParameter("code", "0"); listEvent = query.setCacheable(true).list(); query = session.createQuery("FROM City where cityName=:citycode "); query.setParameter("citycode", city.getCityName()); ArrayList<City> citylist = (ArrayList<City>) query.setCacheable(true).list(); for (int l = 0; l < listSsc.size(); l++) { Ssc ssc = listSsc.get(l); query = session.createQuery("FROM Event where status = 1 and sscName=:ssccode "); query.setParameter("ssccode", ssc.getSscName()); listEvent = query.setCacheable(true).list(); query = session.createQuery("FROM Ssc where sscName=:ssccode"); query.setParameter("ssccode", ssc.getSscName()); ArrayList<Ssc> ssclist = (ArrayList<Ssc>) query.setCacheable(true).list(); } // close ssc for loop } //close city for loop } // branch for loop } //close district for loop } //close bu for loop //listEGreeting = session.createQuery("FROM E_Greeting where status = 1").setCacheable(true).list(); Date edate = new Date(); log.log(Level.INFO, "Total Time " + (edate.getTime() - sdate.getTime())); session.flush(); session.clear(); session.close(); } catch (Exception e) { log.log(Level.INFO, "ImoUtilityDate --> getEventCache --> Exception " + e); e.printStackTrace(); LogsMaintenance logsMain = new LogsMaintenance(); StringWriter errors = new StringWriter(); e.printStackTrace(new PrintWriter(errors)); logsMain.insertLogs("IMOUtilityData", Level.SEVERE + "", errors.toString()); } finally { try { HibernateFactory.close(session); } catch (Exception e) { e.printStackTrace(); } } }
From source file:com.quix.aia.cn.imo.utilities.ImoUtilityData.java
License:Open Source License
public void getAnnouncementCache() { log.log(Level.INFO, "ImoUtilityDate --> getAnnouncementCache"); Session session = null;//from ww w . j a va2s .c o m Transaction tx; List<Announcement> listAnnouncement = null; List<Bu> listbu = null; List<District> listdist = null; List<Branch> listbranch = null; List<City> listcity = null; List<Ssc> listSsc = null; List<Office> listOffice = null; ArrayList al = new ArrayList(); try { Query query = null; session = HibernateFactory.openSession(); Date sdate = new Date(); log.log(Level.INFO, "Start Time " + sdate.getTime()); listbu = session.createQuery("FROM Bu where status = 1").setCacheable(true).list(); listdist = session.createQuery("FROM District where status = 1").setCacheable(true).list(); listbranch = session.createQuery("FROM Branch where status = 1").setCacheable(true).list(); listcity = session.createQuery("FROM City ").setCacheable(true).list(); listSsc = session.createQuery("FROM Ssc").setCacheable(true).list(); listOffice = session.createQuery("FROM Office ").setCacheable(true).list(); listOffice = session.createQuery("FROM Office order by sscName").setCacheable(true).list(); listbu = session.createQuery("FROM Bu where status = 1 order by buName").setCacheable(true).list(); listdist = session.createQuery("FROM District where status = 1 order by districtName") .setCacheable(true).list(); listbranch = session.createQuery("FROM Branch where status = 1 order by branchName").setCacheable(true) .list(); listcity = session.createQuery("FROM City order by cityName").setCacheable(true).list(); listSsc = session.createQuery("FROM Ssc order by sscName").setCacheable(true).list(); for (int i = 0; i < listbu.size(); i++) { Bu bu = listbu.get(i); query = session .createQuery("FROM Announcement where status = 1 and buCode=:bucode and district=0 "); query.setParameter("bucode", bu.getBuCode()); listAnnouncement = query.setCacheable(true).list(); query = session.createQuery("FROM Bu where status = 1 and buCode=:bucode "); query.setParameter("bucode", bu.getBuCode()); ArrayList<Bu> bulist = (ArrayList<Bu>) query.setCacheable(true).list(); for (int j = 0; j < listdist.size(); j++) { District dist = listdist.get(j); query = session.createQuery( "FROM Announcement where status = 1 and district=:distcode and branchCode=0 "); query.setParameter("distcode", dist.getDistrictCode()); listAnnouncement = query.setCacheable(true).list(); query = session.createQuery("FROM District where status = 1 and districtCode=:distcode "); query.setParameter("distcode", dist.getDistrictCode()); ArrayList<District> distlist = (ArrayList<District>) query.setCacheable(true).list(); for (int a = 0; a < listbranch.size(); a++) { Branch branch = listbranch.get(a); query = session.createQuery( "FROM Announcement where status = 1 and branchCode=:branch and cityCode=:code "); query.setParameter("branch", branch.getBranchCode()); query.setParameter("code", "0"); listAnnouncement = query.setCacheable(true).list(); query = session.createQuery("FROM Branch where status = 1 and branchCode=:branch "); query.setParameter("branch", branch.getBranchCode()); ArrayList<Branch> branchlist = (ArrayList<Branch>) query.setCacheable(true).list(); for (int k = 0; k < listcity.size(); k++) { City city = listcity.get(k); query = session.createQuery( "FROM Announcement where status = 1 and cityCode=:citycode and sscCode=:code "); query.setParameter("citycode", city.getCityName()); query.setParameter("code", "0"); listAnnouncement = query.setCacheable(true).list(); query = session.createQuery("FROM City where cityName=:citycode "); query.setParameter("citycode", city.getCityName()); ArrayList<City> citylist = (ArrayList<City>) query.setCacheable(true).list(); for (int l = 0; l < listSsc.size(); l++) { Ssc ssc = listSsc.get(l); query = session .createQuery("FROM Announcement where status = 1 and sscCode=:ssccode "); query.setParameter("ssccode", ssc.getSscName()); listAnnouncement = query.setCacheable(true).list(); query = session.createQuery("FROM Ssc where sscName=:ssccode"); query.setParameter("ssccode", ssc.getSscName()); ArrayList<Ssc> ssclist = (ArrayList<Ssc>) query.setCacheable(true).list(); for (int m = 0; m < listOffice.size(); m++) { Office office = listOffice.get(m); query = session.createQuery( "FROM Announcement where status = 1 and officeCode=:code "); query.setParameter("code", office.getOfficeName()); listAnnouncement = query.setCacheable(true).list(); query = session.createQuery("FROM Office where officeName=:code"); query.setParameter("code", office.getOfficeName()); ArrayList<Office> officelist = (ArrayList<Office>) query.setCacheable(true) .list(); } // close Office for loop } // close ssc for loop } //close city for loop } // branch for loop } //close district for loop } //close bu for loop //listEGreeting = session.createQuery("FROM E_Greeting where status = 1").setCacheable(true).list(); Date edate = new Date(); log.log(Level.INFO, "Total Time " + (edate.getTime() - sdate.getTime())); session.flush(); session.clear(); session.close(); } catch (Exception e) { log.log(Level.INFO, "ImoUtilityDate --> getAnnouncementCache --> Exception " + e); e.printStackTrace(); LogsMaintenance logsMain = new LogsMaintenance(); StringWriter errors = new StringWriter(); e.printStackTrace(new PrintWriter(errors)); logsMain.insertLogs("IMOUtilityData", Level.SEVERE + "", errors.toString()); } finally { try { HibernateFactory.close(session); } catch (Exception e) { e.printStackTrace(); } } }
From source file:com.quix.aia.cn.imo.utilities.ImoUtilityData.java
License:Open Source License
public void getPresenterCache() { log.log(Level.INFO, "ImoUtilityDate --> getPresenterCache"); Session session = null;//from w w w . j a v a 2s.c om Transaction tx; List<Presenter> listPresenter = null; List<Bu> listbu = null; List<District> listdist = null; List<City> listcity = null; List<Branch> listbranch = null; List<Ssc> listSsc = null; List<Office> listOffice = null; ArrayList al = new ArrayList(); try { Query query = null; session = HibernateFactory.openSession(); Date sdate = new Date(); log.log(Level.INFO, "Start Time " + sdate.getTime()); listbu = session.createQuery("FROM Bu where status = 1").setCacheable(true).list(); listdist = session.createQuery("FROM District where status = 1").setCacheable(true).list(); listbranch = session.createQuery("FROM Branch where status = 1").setCacheable(true).list(); listcity = session.createQuery("FROM City where status = 1").setCacheable(true).list(); listSsc = session.createQuery("FROM Ssc where status = 1").setCacheable(true).list(); listOffice = session.createQuery("FROM Office where status = 1").setCacheable(true).list(); listbu = session.createQuery("FROM Bu where status = 1 order by buName").setCacheable(true).list(); listdist = session.createQuery("FROM District where status = 1 order by districtName") .setCacheable(true).list(); listbranch = session.createQuery("FROM Branch where status = 1 order by branchName").setCacheable(true) .list(); listcity = session.createQuery("FROM City where status = 1 order by cityName").setCacheable(true) .list(); listSsc = session.createQuery("FROM Ssc where status = 1 order by sscName").setCacheable(true).list(); listOffice = session.createQuery("FROM Office where status = 1 order by sscName").setCacheable(true) .list(); for (int i = 0; i < listbu.size(); i++) { Bu bu = listbu.get(i); query = session.createQuery("FROM Presenter where status = 1 and buCode=:bucode and district=0 "); query.setParameter("bucode", bu.getBuCode()); listPresenter = query.setCacheable(true).list(); query = session.createQuery("FROM Bu where status = 1 and buCode=:bucode "); query.setParameter("bucode", bu.getBuCode()); ArrayList<Bu> bulist = (ArrayList<Bu>) query.setCacheable(true).list(); for (int j = 0; j < listdist.size(); j++) { District dist = listdist.get(j); query = session.createQuery( "FROM Presenter where status = 1 and district=:distcode and branchCode=0 "); query.setParameter("distcode", dist.getDistrictCode()); listPresenter = query.setCacheable(true).list(); query = session.createQuery("FROM District where status = 1 and districtCode=:distcode "); query.setParameter("distcode", dist.getDistrictCode()); ArrayList<District> distlist = (ArrayList<District>) query.setCacheable(true).list(); for (int a = 0; a < listbranch.size(); a++) { Branch branch = listbranch.get(a); query = session.createQuery( "FROM Presenter where status = 1 and branchCode=:branch and cityCode=0 "); query.setParameter("branch", branch.getBranchCode()); listPresenter = query.setCacheable(true).list(); query = session.createQuery("FROM Branch where status = 1 and branchCode=:branch "); query.setParameter("branch", branch.getBranchCode()); ArrayList<Branch> branchlist = (ArrayList<Branch>) query.setCacheable(true).list(); for (int k = 0; k < listcity.size(); k++) { City city = listcity.get(k); query = session.createQuery( "FROM Presenter where status = 1 and cityCode=:citycode and sscCode=0 "); query.setParameter("citycode", city.getCityCode()); listPresenter = query.setCacheable(true).list(); query = session.createQuery("FROM City where status = 1 and cityCode=:citycode "); query.setParameter("citycode", city.getCityCode()); ArrayList<City> citylist = (ArrayList<City>) query.setCacheable(true).list(); for (int l = 0; l < listSsc.size(); l++) { Ssc ssc = listSsc.get(l); query = session .createQuery("FROM Presenter where status = 1 and sscCode=:ssccode "); query.setParameter("ssccode", ssc.getSscCode()); listPresenter = query.setCacheable(true).list(); query = session.createQuery("FROM Ssc where status = 1 and sscCode=:ssccode"); query.setParameter("ssccode", ssc.getSscCode()); ArrayList<Ssc> ssclist = (ArrayList<Ssc>) query.setCacheable(true).list(); for (int m = 0; m < listOffice.size(); m++) { Office office = listOffice.get(m); query = session.createQuery( "FROM Presenter where status = 1 and officeCode=:code "); query.setParameter("code", office.getOfficeCode()); listPresenter = query.setCacheable(true).list(); query = session .createQuery("FROM Office where status = 1 and officeCode=:code"); query.setParameter("code", office.getOfficeCode()); ArrayList<Office> officelist = (ArrayList<Office>) query.setCacheable(true) .list(); } // close Office for loop } // close ssc for loop } //close city for loop } // close branch for loop } //close district for loop } //close bu for loop //listEGreeting = session.createQuery("FROM E_Greeting where status = 1").setCacheable(true).list(); Date edate = new Date(); log.log(Level.INFO, "Total Time " + (edate.getTime() - sdate.getTime())); session.flush(); session.clear(); session.close(); } catch (Exception e) { log.log(Level.INFO, "ImoUtilityDate --> getPresenterCache --> Exception " + e); e.printStackTrace(); LogsMaintenance logsMain = new LogsMaintenance(); StringWriter errors = new StringWriter(); e.printStackTrace(new PrintWriter(errors)); logsMain.insertLogs("IMOUtilityData", Level.SEVERE + "", errors.toString()); } finally { try { HibernateFactory.close(session); } catch (Exception e) { e.printStackTrace(); } } }
From source file:com.quix.aia.cn.imo.utilities.ImoUtilityData.java
License:Open Source License
public void getInterviewCache() { log.log(Level.INFO, "ImoUtilityDate --> getInterviewCache"); Session session = null;/*from w w w. j ava 2 s. c o m*/ Transaction tx; List<Interview> listInterview = null; List<Bu> listbu = null; List<District> listdist = null; List<Branch> listbranch = null; List<City> listcity = null; List<Ssc> listSsc = null; List<Office> listOffice = null; ArrayList al = new ArrayList(); try { Query query = null; session = HibernateFactory.openSession(); Date sdate = new Date(); log.log(Level.INFO, "Start Time " + sdate.getTime()); listbu = session.createQuery("FROM Bu where status = 1").setCacheable(true).list(); listdist = session.createQuery("FROM District where status = 1").setCacheable(true).list(); listbranch = session.createQuery("FROM Branch where status = 1").setCacheable(true).list(); listcity = session.createQuery("FROM City ").setCacheable(true).list(); listSsc = session.createQuery("FROM Ssc ").setCacheable(true).list(); listOffice = session.createQuery("FROM Office").setCacheable(true).list(); listbu = session.createQuery("FROM Bu where status = 1 order by buName").setCacheable(true).list(); listdist = session.createQuery("FROM District where status = 1 order by districtName") .setCacheable(true).list(); listbranch = session.createQuery("FROM Branch where status = 1 order by branchName").setCacheable(true) .list(); listcity = session.createQuery("FROM City order by cityName").setCacheable(true).list(); listSsc = session.createQuery("FROM Ssc order by sscName").setCacheable(true).list(); listOffice = session.createQuery("FROM Office order by officeName").setCacheable(true).list(); for (int i = 0; i < listbu.size(); i++) { Bu bu = listbu.get(i); query = session.createQuery("FROM Interview where status = 1 and buCode=:bucode and district=0 "); query.setParameter("bucode", bu.getBuCode()); listInterview = query.setCacheable(true).list(); query = session.createQuery("FROM Bu where status = 1 and buCode=:bucode "); query.setParameter("bucode", bu.getBuCode()); ArrayList<Bu> bulist = (ArrayList<Bu>) query.setCacheable(true).list(); for (int j = 0; j < listdist.size(); j++) { District dist = listdist.get(j); query = session.createQuery( "FROM Interview where status = 1 and district=:distcode and branchCode=0 "); query.setParameter("distcode", dist.getDistrictCode()); listInterview = query.setCacheable(true).list(); query = session.createQuery("FROM District where status = 1 and districtCode=:distcode "); query.setParameter("distcode", dist.getDistrictCode()); ArrayList<District> distlist = (ArrayList<District>) query.setCacheable(true).list(); for (int a = 0; a < listbranch.size(); a++) { Branch branch = listbranch.get(a); query = session.createQuery( "FROM Interview where status = 1 and branchCode=:branch and cityCode=:code "); query.setParameter("branch", branch.getBranchCode()); query.setParameter("code", "0"); listInterview = query.setCacheable(true).list(); query = session.createQuery("FROM Branch where status = 1 and branchCode=:branch "); query.setParameter("branch", branch.getBranchCode()); ArrayList<Branch> branchlist = (ArrayList<Branch>) query.setCacheable(true).list(); for (int k = 0; k < listcity.size(); k++) { City city = listcity.get(k); query = session.createQuery( "FROM Interview where status = 1 and cityCode=:citycode and sscCode=:code "); query.setParameter("citycode", city.getCityName()); query.setParameter("code", "0"); listInterview = query.setCacheable(true).list(); query = session.createQuery("FROM City where cityName=:citycode "); query.setParameter("citycode", city.getCityName()); ArrayList<City> citylist = (ArrayList<City>) query.setCacheable(true).list(); for (int l = 0; l < listSsc.size(); l++) { Ssc ssc = listSsc.get(l); query = session .createQuery("FROM Interview where status = 1 and sscCode=:ssccode "); query.setParameter("ssccode", ssc.getSscName()); listInterview = query.setCacheable(true).list(); query = session.createQuery("FROM Ssc where sscName=:ssccode"); query.setParameter("ssccode", ssc.getSscName()); ArrayList<Ssc> ssclist = (ArrayList<Ssc>) query.setCacheable(true).list(); for (int m = 0; m < listOffice.size(); m++) { Office office = listOffice.get(m); query = session.createQuery( "FROM Interview where status = 1 and officeCode=:code "); query.setParameter("code", office.getOfficeName()); listInterview = query.setCacheable(true).list(); query = session.createQuery("FROM Office where officeName=:code"); query.setParameter("code", office.getOfficeName()); ArrayList<Office> officelist = (ArrayList<Office>) query.setCacheable(true) .list(); } // close Office for loop } // close ssc for loop } //close city for loop } // close branch for loop } //close district for loop } //close bu for loop //listEGreeting = session.createQuery("FROM E_Greeting where status = 1").setCacheable(true).list(); Date edate = new Date(); log.log(Level.INFO, "Total Time " + (edate.getTime() - sdate.getTime())); } catch (Exception e) { log.log(Level.INFO, "ImoUtilityDate --> getInterviewCache --> Exception " + e); e.printStackTrace(); LogsMaintenance logsMain = new LogsMaintenance(); StringWriter errors = new StringWriter(); e.printStackTrace(new PrintWriter(errors)); logsMain.insertLogs("IMOUtilityData", Level.SEVERE + "", errors.toString()); } finally { try { HibernateFactory.close(session); } catch (Exception e) { e.printStackTrace(); } } }