List of usage examples for org.hibernate SQLQuery addEntity
SQLQuery<T> addEntity(String tableAlias, Class entityType);
From source file:com.userweave.dao.impl.SurveyExecutionDaoImpl.java
License:Open Source License
@Override public List<SurveyExecution> findByStudy(Study study, FilterFunctor filterFunctor) { SurveyExecutionDependentQuery query = new SurveyExecutionDependentQuery("se", "id"); // query for ITMTestResult QueryEntity result = new QueryEntity(getEntityName(), "se"); query.setResult("{se.*}"); query.addQueryEntity(result);/* ww w . j a va2 s . c o m*/ // only results for this configuration query.addAndCondition(PropertyCondition.equals("se.study_id", study.getId())); if (filterFunctor != null) { filterFunctor.apply(query); } SQLQuery q = new QueryTemplate(query).createSqlQuery((getCurrentSession())); q.addEntity("se", getPersistentClass()); long startTime = System.currentTimeMillis(); List<SurveyExecution> rv = q.list(); long overallTime = System.currentTimeMillis() - startTime; logger.info("EXECUTION TIME: " + overallTime + " milliseconds (" + query.toString() + ")"); return rv; }
From source file:com.userweave.dao.impl.SurveyExecutionDaoImpl.java
License:Open Source License
@Override public List<SurveyExecution> findFinishedByStudy(Study study, FilterFunctor filterFunctor) { SurveyExecutionDependentQuery query = new SurveyExecutionDependentQuery("se", "id"); QueryEntity result = new QueryEntity(getEntityName(), "se"); query.setResult("{se.*}"); query.addQueryEntity(result);//from w w w . ja v a 2 s . co m query.addAndCondition(PropertyCondition.equals("se.state", SurveyExecutionState.COMPLETED)); SQLQuery q = new QueryTemplate(query).createSqlQuery((getCurrentSession())); q.addEntity("se", getPersistentClass()); List<SurveyExecution> rv = q.list(); return rv; }
From source file:com.userweave.dao.impl.TestResultDaoImpl.java
License:Open Source License
/** * Gets called by rrtReportPanel/* ww w.jav a 2s.com*/ */ @Override public List<T> findValidResults(ModuleConfigurationWithResultsEntity configuration, FilterFunctor filterFunctor) { SurveyExecutionDependentQuery query = createQuery(configuration, filterFunctor); if (query.getHasGroupBy()) { query.setGroupBy("result.id, " + "result.configuration_id, " + "result.executionFinished, " + "result.executionStarted, " + "result.executionTime, " + "result.surveyExecution_id"); } SQLQuery q = new QueryTemplate(query).createSqlQuery(getCurrentSession()); q.addEntity("result", getPersistentClass()); return q.list(); }
From source file:com.userweave.module.methoden.iconunderstandability.dao.impl.IconTermMappingDaoImpl.java
License:Open Source License
@SuppressWarnings("unchecked") @Override//from ww w. j av a 2s .c om public List<IconTermMapping> findValidResults(IconTermMatchingConfigurationEntity configuration, FilterFunctor filterFunctor) { //TODO query.setResult(result); SurveyExecutionDependentQuery query = createValidResultQuery(configuration, filterFunctor); SQLQuery q = new QueryTemplate(query).createSqlQuery((getCurrentSession())); q.addEntity("mapping", getPersistentClass()); return q.list(); }
From source file:com.userweave.module.methoden.questionnaire.dao.AnswerDaoImpl.java
License:Open Source License
@SuppressWarnings("unchecked") @Override//from w w w .jav a2 s . com public List<AnswerToSingleAnswerQuestion> getValidAnswersForQuestion(SingleAnswerQuestion question, FilterFunctor filterFunctor) { QueryObject queryObject = getQueryObject(question, filterFunctor, "answer", "singleanswer"); queryObject.setResult("{qa.*}"); if (queryObject.getHasGroupBy()) { queryObject.setGroupBy("qa.id, qa.question_id, qa.result_id, qa.answer_id"); } SQLQuery q = new QueryTemplate(queryObject).createSqlQuery(getCurrentSession()); q.addEntity("qa", AnswerToSingleAnswerQuestion.class); return q.list(); }
From source file:com.userweave.module.methoden.questionnaire.dao.AnswerDaoImpl.java
License:Open Source License
@SuppressWarnings("unchecked") @Override/*from ww w.ja v a 2s. c o m*/ public List<MultipleAnswersAnwer> getValidAnswersForQuestion(MultipleAnswersQuestion question, FilterFunctor filterFunctor) { QueryObject queryObject = getQueryObject(question, filterFunctor, "answer", "multipleanswer"); queryObject.setResult("{qa.*}"); if (queryObject.getHasGroupBy()) { queryObject.setGroupBy("qa.id, qa.question_id, qa.result_id"); } SQLQuery q = new QueryTemplate(queryObject).createSqlQuery(getCurrentSession()); q.addEntity("qa", MultipleAnswersAnwer.class); return q.list(); }
From source file:com.userweave.module.methoden.questionnaire.dao.AnswerDaoImpl.java
License:Open Source License
@SuppressWarnings("unchecked") @Override//w w w .j a v a 2s . c om public List<FreeAnwer> getValidAnswersForQuestion(FreeQuestion question, FilterFunctor filterFunctor) { QueryObject queryObject; SQLQuery q; if (question.getAnswerType().equals(FreeQuestion.AnswerType.NUMBER)) { queryObject = getQueryObject(question, filterFunctor, "answer", "freenumberanswer"); queryObject.setResult("{qa.*}"); if (queryObject.getHasGroupBy()) { queryObject.setGroupBy("qa.id, qa.question_id, qa.result_id, qa.number"); } q = new QueryTemplate(queryObject).createSqlQuery(getCurrentSession()); q.addEntity("qa", FreeNumberAnswer.class); } else { queryObject = getQueryObject(question, filterFunctor, "answer", "freetextanswer"); queryObject.setResult("{qa.*}"); if (queryObject.getHasGroupBy()) { queryObject.setGroupBy("qa.id, qa.question_id, qa.result_id, qa.TEXT"); } q = new QueryTemplate(queryObject).createSqlQuery(getCurrentSession()); q.addEntity("qa", FreeTextAnswer.class); } return q.list(); }
From source file:com.userweave.module.methoden.questionnaire.dao.AnswerDaoImpl.java
License:Open Source License
@SuppressWarnings("unchecked") @Override//from www . j av a2s .c om public List<Object[]> getValidAnswersForQuestion(MultipleRatingQuestion question, FilterFunctor filterFunctor) { QueryObject queryObject = getQueryObject(question, filterFunctor, "singleratinganswer", "singleratinganswer"); queryObject.setResult("{qa.*}, r_qa.ratingterm_id"); if (queryObject.getHasGroupBy()) { queryObject.setGroupBy("qa.id, " + "qa.multipleRatingAnswer_id, " + "qa.rating, " + "qa.ratingTerm_id, " + "r_qa.ratingterm_id"); } SQLQuery q = new QueryTemplate(queryObject).createSqlQuery(getCurrentSession()); q.addEntity("qa", SingleRatingAnswer.class); q.addScalar("ratingterm_id", Hibernate.INTEGER); return q.list(); }
From source file:com.userweave.module.methoden.questionnaire.dao.AnswerDaoImpl.java
License:Open Source License
@SuppressWarnings("unchecked") @Override// w w w .j a v a 2 s .c om public List<SingleDimensionAnswer> getValidAnswersForQuestion(DimensionsQuestion question, FilterFunctor filterFunctor) { QueryObject query = getQueryObject(question, filterFunctor, "singledimensionanswer", "singledimensionanswer"); query.setResult("{qa.*}"); if (query.getHasGroupBy()) { query.setGroupBy("qa.id, " + "qa.antipodePair_id, " + "qa.multipleDimensionsAnswer_id, " + "qa.rating"); } SQLQuery q = new QueryTemplate(query).createSqlQuery(getCurrentSession()); q.addEntity("qa", SingleDimensionAnswer.class); return q.list(); }
From source file:dao.ParametrDao.java
public List<Object[]> getParamsAndNeedsFromCat(Long catId) { String sql = "select p.*,l.req_type from param_category_link l left join parametr p on l.parametr_id=p.parametr_id where l.category_id=:catId order by p.name asc"; SQLQuery query = getCurrentSession().createSQLQuery(sql); query.addEntity("p", Parametr.class); query.addScalar("req_type", StandardBasicTypes.INTEGER); query.setParameter("catId", catId); return query.list(); }