List of usage examples for org.hibernate Criteria setFetchMode
public Criteria setFetchMode(String associationPath, FetchMode mode) throws HibernateException;
From source file:com.indicator_engine.dao.GLAQuestionDaoImpl.java
License:Open Source License
/** * Loads an Question from Database./*from w w w. j a v a 2 s. co m*/ * @param ID Question ID to be searched and loaded. * @return The loaded Question with its associated Indicators. */ @Override @Transactional public GLAQuestion loadByQuestionID(long ID) { Session session = factory.getCurrentSession(); GLAQuestion glaQuestion = null; Criteria criteria = session.createCriteria(GLAQuestion.class); criteria.setFetchMode("glaIndicators", FetchMode.JOIN); criteria.setFetchMode("glaQuestionProps", FetchMode.JOIN); criteria.add(Restrictions.eq("id", ID)); criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); Object result = criteria.uniqueResult(); if (result != null) { glaQuestion = (GLAQuestion) result; } return glaQuestion; }
From source file:com.indicator_engine.dao.GLAQuestionDaoImpl.java
License:Open Source License
/** * Loads an existing Indicator from the Database. Looks up using name in the Database. It does a similarity search in the database. * @param questionName Name of the Indicator used for lookup. * @return A List of similarly named Indicators present in the Database. *//* w w w . j av a2 s .co m*/ @Override @Transactional public List<GLAQuestion> loadByQuestionName(String questionName, boolean exact) { Session session = factory.getCurrentSession(); questionName = "%" + questionName + "%"; Criteria criteria = session.createCriteria(GLAQuestion.class); criteria.setFetchMode("glaIndicators", FetchMode.JOIN); criteria.setFetchMode("glaQuestionProps", FetchMode.JOIN); if (exact) criteria.add(Restrictions.eq("question_name", questionName)); else criteria.add(Restrictions.ilike("question_name", questionName)); criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); return criteria.list(); }
From source file:com.indicator_engine.dao.GLAQuestionDaoImpl.java
License:Open Source License
/** * Updates the Execution Statistics Counter of a Specific Question. * @param ID Question ID to be searched and updated. * *//* w w w. j av a2 s . co m*/ @Override @Transactional public void updateStatistics(long ID) { Session session = factory.getCurrentSession(); GLAQuestion glaQuestion = null; Calendar calendar = Calendar.getInstance(); java.util.Date now = calendar.getTime(); Criteria criteria = session.createCriteria(GLAQuestion.class); criteria.setFetchMode("glaIndicators", FetchMode.JOIN); criteria.setFetchMode("glaQuestionProps", FetchMode.JOIN); criteria.add(Restrictions.eq("id", ID)); criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); Object result = criteria.uniqueResult(); if (result != null) { glaQuestion = (GLAQuestion) result; } glaQuestion.getGlaQuestionProps().setLast_executionTime(new java.sql.Timestamp(now.getTime())); glaQuestion.getGlaQuestionProps() .setTotalExecutions(glaQuestion.getGlaQuestionProps().getTotalExecutions() + 1); factory.getCurrentSession().saveOrUpdate(glaQuestion); }
From source file:com.indicator_engine.dao.GLAQuestionDaoImpl.java
License:Open Source License
@Override @Transactional/*from w ww.ja v a 2s . c o m*/ public List<GLAQuestion> searchQuestionsName(String searchParameter, boolean exactSearch, String colName, String sortDirection, boolean sort) { if (!exactSearch) searchParameter = "%" + searchParameter + "%"; Session session = factory.getCurrentSession(); Criteria criteria = session.createCriteria(GLAQuestion.class); criteria.setFetchMode("glaIndicators", FetchMode.JOIN); criteria.setFetchMode("glaQuestionProps", FetchMode.JOIN); if (!exactSearch) criteria.add(Restrictions.ilike("question_name", searchParameter)); else criteria.add(Restrictions.eq("question_name", searchParameter)); criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); if (sort) { if (sortDirection.equals("asc")) criteria.addOrder(Order.asc(colName)); else criteria.addOrder(Order.desc(colName)); } return criteria.list(); }
From source file:com.indicator_engine.dao.GLAUserDaoImpl.java
License:Open Source License
@Override @Transactional(readOnly = true)//from w w w . j av a 2 s. c om public List<GLAUser> loadUsersRange(long startRange, long endRange) { Session session = factory.getCurrentSession(); Criteria criteria = session.createCriteria(GLAUser.class); criteria.setFetchMode("events", FetchMode.JOIN); criteria.add(Restrictions.ge("id", startRange)); criteria.add(Restrictions.le("id", endRange)); return criteria.list(); }
From source file:com.indicator_engine.dao.GLAUserDaoImpl.java
License:Open Source License
@Override @Transactional(readOnly = true)/*w w w .j ava 2 s .c om*/ public List<GLAUser> loadAll(String colName, String sortDirection, boolean sort) { Session session = factory.getCurrentSession(); Criteria criteria = session.createCriteria(GLAUser.class); criteria.setFetchMode("events", FetchMode.JOIN); criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); if (sort) { if (sortDirection.equals("asc")) criteria.addOrder(Order.asc(colName)); else criteria.addOrder(Order.desc(colName)); } return criteria.list(); }
From source file:com.indicator_engine.dao.GLAUserDaoImpl.java
License:Open Source License
@Override @Transactional(readOnly = true)//from w ww . ja v a 2s .c o m public List<GLAUser> searchLikeUsers(String searchParameter, String colName, String sortDirection, boolean sort) { searchParameter = "%" + searchParameter + "%"; Session session = factory.getCurrentSession(); Criteria criteria = session.createCriteria(GLAUser.class); criteria.setFetchMode("events", FetchMode.JOIN); criteria.add(Restrictions.ilike("username", searchParameter)); if (sort) { if (sortDirection.equals("asc")) criteria.addOrder(Order.asc(colName)); else criteria.addOrder(Order.desc(colName)); } return criteria.list(); }
From source file:com.indicator_engine.dao.SecurityRoleEntityDaoImpl.java
License:Open Source License
@Override @Transactional//www .j av a 2 s .c o m public List<SecurityRoleEntity> searchRolesByID(long UID) { Session session = factory.getCurrentSession(); Criteria criteria = session.createCriteria(SecurityRoleEntity.class); criteria.setFetchMode("userCredentials", FetchMode.JOIN); criteria.createAlias("userCredentials", "uc"); criteria.add(Restrictions.eq("uc.uid", UID)); return criteria.list(); }
From source file:com.inkubator.hrm.dao.impl.AppraisalProgramEmpAssesorDaoImpl.java
@Override public List<AppraisalProgramEmpAssesor> getAllBy(Long appraisalId, Long empId) { Criteria criteria = getCurrentSession().createCriteria(getEntityClass()); criteria.createAlias("appraisalProgram", "ap"); criteria.createAlias("empDataByEmpId", "em"); criteria.setFetchMode("appraisalProgram", FetchMode.JOIN); criteria.setFetchMode("empDataByAssesorEmpId", FetchMode.JOIN); criteria.setFetchMode("empDataByAssesorEmpId.jabatanByJabatanId", FetchMode.JOIN); criteria.setFetchMode("empDataByAssesorEmpId.bioData", FetchMode.JOIN); criteria.add(Restrictions.eq("ap.id", appraisalId)); criteria.add(Restrictions.eq("em.id", empId)); return criteria.list(); }
From source file:com.inkubator.hrm.dao.impl.ApprovalDefinitionLoanDaoImpl.java
@Override public List<ApprovalDefinitionLoan> getByLoanId(Long id) { Criteria criteria = getCurrentSession().createCriteria(getEntityClass()); criteria.setFetchMode("loanNewSchema", FetchMode.JOIN); criteria.setFetchMode("approvalDefinition", FetchMode.JOIN); criteria.add(Restrictions.eq("loanNewSchema.id", id)); return criteria.list(); }