Before/After uses Criteria from Hibernate

BEFORE: public List<Question> getQualitativesBySurveyId(UUID id) { return getEntityManager() .createQuery( "select instance from " + getTypeClass().getName() + " as instance" + " join fetch instance.question" + " where instance.survey.id = :surveyId and instance.question.type = questionType" + " order by instance.order") .setParameter("surveyId", id) .setParameter("questionType", QuestionType.QUALITATIVE) .getResultList(); } AFTER public List<Question> getQualitativesBySurveyId(UUID surveyId){ return getSession().createCriteria(Question.class) .add(Restrictions.eq("type", QuestionType.QUALITATIVE)) .add(Restrictions.eq("surveyId", surveyId)) .list(); }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.