package main.java.dao;

import java.util.List;

import org.hibernate.SQLQuery;

import main.java.domain.Answer;

public class AnswerDao extends GenericDaoImpl<Answer> {
	@SuppressWarnings("unchecked")
	public List<Object[]> getCSV(List<Integer> questionIds) {
		getSession().beginTransaction();
		String SQL = "select * from (select userid,questionid,answer from ntr_answer) PIVOT(max(answer) for questionid in(";
		for(int i : questionIds) {
			SQL += i+",";
		}
		SQL = SQL.substring(0, SQL.length()-1)+"))";
		SQLQuery SQLquery = getSession().createSQLQuery(SQL);
		List<Object[]> rows = SQLquery.list();
		return rows;
	}
}

@@ -41,16 +41,44 @@
 .List;%0A%0A
+import org.hibernate.Query;%0A
 import o
@@ -190,16 +190,250 @@
 swer%3E %7B%0A
+%09public List%3CAnswer%3E getAnswersByQuestionId(int questionId) %7B%0A%09%09getSession().beginTransaction();%0A%09%09Query query = getSession().createQuery(%22from Question where survey.id =:id%22).setParameter(%22id%22, questionId);%0A%09%09return query.list();%0A%09%7D%0A
 %09@Suppre

fix getAnswersByQuestionId