i want to apply joins ,on this code,
public List<SnStudentAssessment> getClassAssessment( AssessmentCommand assessmentCommand, String username, SnSchool snSchool) throws DataAccessException, java.sql.SQLException, ParseException {
List<SnStudentAssessment> marksList = null;
Session session = this.getSession(); Transaction transaction = session.beginTransaction(); Query query = null; StringBuffer queryBuffer = new StringBuffer( "from com.tsb.nirvahak.student.hibernate.SnStudentAssessment"); if (assessmentCommand.getAssessmentType().equals("I")) { HashMap searchFilters = new HashMap(); searchFilters.put("month", new SearchFilterData("month", assessmentCommand.getMonth(), SearchFilterData.TYPE_STRING_STR)); searchFilters.put("year", new SearchFilterData("year", assessmentCommand.getYear(), SearchFilterData.TYPE_NUMERIC_STR)); searchFilters.put("class_id", new SearchFilterData("class_id", assessmentCommand.getKlassId(), SearchFilterData.TYPE_NUMERIC_STR)); Iterator iterator = searchFilters.keySet().iterator(); boolean hasNext = iterator.hasNext(); if (hasNext) { queryBuffer.append(" where "); } HibernateDaoUtil.appendGridFilter(queryBuffer, searchFilters);
query = session.createQuery(queryBuffer.toString()); } else if (assessmentCommand.getAssessmentType().equals("T")) { queryBuffer.append("a.classId =:classId and a.term =:term"); query = session.createQuery(queryBuffer.toString()); query.setLong("classId", assessmentCommand.getKlassId()); query.setString("term", assessmentCommand.getTerm()); } else { return new ArrayList<SnStudentAssessment>(); }
marksList = query.list(); Iterator<SnStudentAssessment> iter = query.iterate();
Iterator iterator = marksList.iterator();
while (iter.hasNext()) { SnStudentAssessment assessment = (SnStudentAssessment) iter.next(); assessment.getGrade(); assessment.getMaths(); assessment.getSnStudent().getId(); assessment.getSnStudent().getFirstName(); assessment.getSnStudent().getLastName(); }
transaction.commit(); session.close();
return marksList; }
please help me
|