List of usage examples for org.hibernate FetchMode JOIN
FetchMode JOIN
To view the source code for org.hibernate FetchMode JOIN.
Click Source Link
From source file:com.indicator_engine.dao.GLAIndicatorDaoImpl.java
License:Open Source License
/** * Searches for Indicators based on their Name * * @param searchParameter//from w ww .ja va 2 s . co m * Name to be searched for * @param exactSearch * True for exact Search, False for Similarity Search * @param colName * Column Name to be used for Sorting the results * @param sortDirection * Sort Direction : Ascending/Descending * @param sort * True for sorting Required and False to set sorting of results off. * * @return Returns the Result of Similar or Exact search as a List<GLAIndicator> */ @Override @Transactional public List<GLAIndicator> searchIndicatorsName(String searchParameter, boolean exactSearch, String colName, String sortDirection, boolean sort) { if (!exactSearch) searchParameter = "%" + searchParameter + "%"; Session session = factory.getCurrentSession(); Criteria criteria = session.createCriteria(GLAIndicator.class); criteria.setFetchMode("queries", FetchMode.JOIN); criteria.setFetchMode("glaIndicatorProps", FetchMode.JOIN); if (!exactSearch) criteria.add(Restrictions.ilike("indicator_name", searchParameter)); else criteria.add(Restrictions.eq("indicator_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.GLAIndicatorDaoImpl.java
License:Open Source License
/** * Deletes an existing Indicator using its ID. Deletes the Indicator if found else ignores. * @param indicator_id// w w w . j a v a 2 s .co m * Specific Indicator with this ID to be deleted. */ @Override @Transactional public void deleteIndicator(long indicator_id) { GLAIndicator glaIndicator = null; Session session = factory.getCurrentSession(); Criteria criteria = session.createCriteria(GLAIndicator.class); criteria.setFetchMode("queries", FetchMode.JOIN); criteria.setFetchMode("glaIndicatorProps", FetchMode.JOIN); criteria.add(Restrictions.eq("id", indicator_id)); criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); Object result = criteria.uniqueResult(); if (result != null) { glaIndicator = (GLAIndicator) result; } session.delete(glaIndicator); }
From source file:com.indicator_engine.dao.GLAIndicatorDaoImpl.java
License:Open Source License
/** * Finds an existing Indicator using its name. It does an exact lookup. * @param indicatorName Name of Indicator to be searched in the Database. * @return//from ww w . jav a2 s .c o m * Returns the Indicator ID if a match is found. */ @Override @Transactional public long findIndicatorID(String indicatorName) { Session session = factory.getCurrentSession(); long indicatorID = 0; Criteria criteria = session.createCriteria(GLAIndicator.class); criteria.setFetchMode("queries", FetchMode.JOIN); criteria.setFetchMode("glaIndicatorProps", FetchMode.JOIN); criteria.setProjection(Projections.property("id")); criteria.add(Restrictions.eq("indicator_name", indicatorName)); criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); Object result = criteria.uniqueResult(); if (result != null) { indicatorID = (long) result; } return indicatorID; }
From source file:com.indicator_engine.dao.GLAIndicatorDaoImpl.java
License:Open Source License
/** * Updates the Execution Statistics Counter of a Specific Indicator. * @param ID Indicator ID to be searched and updated. * *//*from w ww .j av a 2 s . c o m*/ @Override @Transactional public void updateStatistics(long ID) { Session session = factory.getCurrentSession(); GLAIndicator glaIndicator = null; Calendar calendar = Calendar.getInstance(); java.util.Date now = calendar.getTime(); Criteria criteria = session.createCriteria(GLAIndicator.class); criteria.setFetchMode("glaQuestions", FetchMode.JOIN); criteria.setFetchMode("glaIndicatorProps", FetchMode.JOIN); criteria.add(Restrictions.eq("id", ID)); criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); Object result = criteria.uniqueResult(); if (result != null) { glaIndicator = (GLAIndicator) result; } glaIndicator.getGlaIndicatorProps().setLast_executionTime(new java.sql.Timestamp(now.getTime())); glaIndicator.getGlaIndicatorProps() .setTotalExecutions(glaIndicator.getGlaIndicatorProps().getTotalExecutions() + 1); factory.getCurrentSession().saveOrUpdate(glaIndicator); }
From source file:com.indicator_engine.dao.GLAIndicatorDaoImpl.java
License:Open Source License
@Override @Transactional//from w w w.ja v a2s .c o m public long findQuestionID(long indicatorID) { Session session = factory.getCurrentSession(); Criteria criteria = session.createCriteria(GLAIndicator.class); criteria.setFetchMode("glaIndicatorProps", FetchMode.JOIN); criteria.createAlias("glaQuestions", "questions"); criteria.setFetchMode("questions", FetchMode.JOIN); criteria.add(Restrictions.eq("id", indicatorID)); criteria.setProjection(Projections.property("questions.id")); return ((Long) criteria.uniqueResult()).longValue(); }
From source file:com.indicator_engine.dao.GLAQuestionDaoImpl.java
License:Open Source License
/** * Lists all the Questions present in the Database. * @param colName//from ww w. jav a 2s .c o m * Column Name to be used for Sorting the results * @param sortDirection * Sort Direction : Ascending/Descending * @param sort * True for sorting Required and False to set sorting of results off. * @return * Listing of all the Questions. * */ @Override @Transactional public List<GLAQuestion> displayAll(String colName, String sortDirection, boolean sort) { Session session = factory.getCurrentSession(); Criteria criteria = session.createCriteria(GLAQuestion.class); criteria.setFetchMode("glaIndicators", FetchMode.JOIN); criteria.setFetchMode("glaQuestionProps", 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.GLAQuestionDaoImpl.java
License:Open Source License
/** * Finds an existing Question using its name. It does an exact lookup. * @param questionName Name of Question to be searched in the Database. * @return//w ww . jav a2 s . c o m * Returns the Question ID if a match is found. */ @Override @Transactional public long findQuestionID(String questionName) { Session session = factory.getCurrentSession(); long indicatorID = 0; Criteria criteria = session.createCriteria(GLAQuestion.class); criteria.setFetchMode("glaIndicators", FetchMode.JOIN); criteria.setFetchMode("glaQuestionProps", FetchMode.JOIN); criteria.setProjection(Projections.property("id")); criteria.add(Restrictions.eq("question_name", questionName)); criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); Object result = criteria.uniqueResult(); if (result != null) { indicatorID = (long) result; } return indicatorID; }
From source file:com.indicator_engine.dao.GLAQuestionDaoImpl.java
License:Open Source License
/** * Loads an Question from Database.//from ww w . j a va2 s .c o 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 a va 2s . c om*/ @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. * *///from w w w . j a va 2s. com @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); }