List of usage examples for org.hibernate SQLQuery list
List<R> list();
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);//from w w w. java2 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 ww. java2 s . c o 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/* w w w . j a v a 2 s . c o m*/ */ @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.dao.impl.TestResultDaoImpl.java
License:Open Source License
@Override public int getValidResultCount(U configuration, FilterFunctor filterFunctor) { SurveyExecutionDependentQuery query = new SurveyExecutionDependentQuery("se", "id"); // query for number of questionnaire results QueryEntity result = new QueryEntity(getEntityResultName(), "result"); query.addQueryEntity(result);/*w w w.j a va 2s.c o m*/ query.setResult("count(se.id)"); // result must match configuration query.addAndCondition(PropertyCondition.equals("result.configuration_id", configuration.getId())); // join on survey execution for filtering query.addLeftJoin(new Join("surveyexecution", "se", "result.surveyexecution_id", "se.id")); // only count started or completed surveys query.addAndCondition(PropertyCondition.greaterOrEqual("se.state", SurveyExecutionState.STARTED.ordinal())); if (filterFunctor != null) { filterFunctor.apply(query); } if (query.getHasGroupBy()) { query.setGroupBy("se.id"); SQLQuery q = new QueryTemplate(query).createSqlQuery(getCurrentSession()); return q.list().size(); } else { SQLQuery q = new QueryTemplate(query).createSqlQuery(getCurrentSession()); return ((BigInteger) q.uniqueResult()).intValue(); } }
From source file:com.userweave.module.methoden.iconunderstandability.dao.impl.IconTermMappingDaoImpl.java
License:Open Source License
@SuppressWarnings("unchecked") @Override/*from w w w .j a v a 2 s .co m*/ 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 ww w .j a va 2 s . c o m*/ 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 w ww . j av a2 s. 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/* www. ja v a2 s. c o m*/ 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 w ww . j a va 2 s . co m 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
@Override public Long getGroupedValidAnswersForMultipleRatingQuestion(MultipleRatingQuestion question, FilterFunctor filterFunctor) {//from w ww . j a va 2 s .c o m QueryObject query = getQueryObject(question, filterFunctor, "singleratinganswer", "singleratinganswer"); query.setResult("count(distinct r_qa.surveyexecution_id)"); SQLQuery q = new QueryTemplate(query).createSqlQuery(getCurrentSession()); if (query.getHasGroupBy()) { return ((Integer) q.list().size()).longValue(); } return ((BigInteger) q.uniqueResult()).longValue(); }