r8r wrote:
Code between sessionFactory.openSession() and session.close():
**please note this is a DAO object**
public static List getFileMovementViewByCaseNo(CaseNo caseNoIn)
throws HibernateException {
Session session = DaoUtil.getFactory().getSession();
//FileMovementView fileMovementResults = (FileMovementView) session.get(FileMovementView.class,caseNo);
Query q = session.createQuery("from FileMovementView as fmv " +
"where (fmv.caseNo.caseCourtSys = :a " +
"and fmv.caseNo.caseType = :b " +
"and fmv.caseNo.caseSerNo = :c " +
"and fmv.caseNo.caseYear = :d) " +
"order by seq desc" ).setMaxResults(1);
q.setParameter("a", caseNoIn.getCaseCourtSys(), Hibernate.STRING);
q.setParameter("b", caseNoIn.getCaseType(), Hibernate.STRING);
q.setParameter("c", caseNoIn.getCaseSerNo(), Hibernate.INTEGER);
q.setParameter("d", caseNoIn.getCaseYear(), Hibernate.INTEGER);
List result = q.list();
getLog().debug("******* fileMovementViewByCaseNo.size() = " + result.size());
return result;
}
** please note the above class is incorrect, shall be the one below **
public static List fetchFileMovementViewByCaseNo(final CaseNo caseNoIn)
throws HibernateException {
final Session session = DaoUtil.getFactory().getSession();
session.get(FileMovementView.class,caseNo);
getLog().debug("******* 1() = " + caseNoIn.getCaseCourtSys());
getLog().debug("******* 2() = " + caseNoIn.getCaseType());
getLog().debug("******* 3() = " + caseNoIn.getCaseSerNo());
getLog().debug("******* 4() = " + caseNoIn.getCaseYear());
List result2 = session.createCriteria(FileMovementView.class).add(Expression.eq(FileMovementView.CASE_NO,(caseNoIn))).setMaxResults(50).list();
getLog().debug("******* yumyumyum = " + result2.size());
getLog().debug("******* fileMovementViewByCaseNo.size() = " + result2.size());
return result2;
}
16:17:59,212 DEBUG [com.company.dao.FileMovementView] ******* 1() = HH
16:17:59,212 DEBUG [com.company.dao.FileMovementView] ******* 2() = A
16:17:59,212 DEBUG [com.company.dao.FileMovementView] ******* 3() = 1248
16:17:59,212 DEBUG [com.company.dao.FileMovementView] ******* 4() = 2001
16:17:59,212 INFO [STDOUT] Hibernate: select * from ( select this.CASE_COURT_SYS as CASE_COU1_0_, this.CASE_TYPE as CASE_TYPE0_, this.CASE_SER_NO as CASE_SER3_0_, this.CASE_YR as CASE_YR0_, this.SEQ as SEQ0_, this.OUT_MOVE_INT_NO as OUT_MOVE6_0_, this.CMS_USER_ID as CMS_USER7_0_, this.IS_OUT as IS_OUT0_, this.CURR_LOC as CURR_LOC0_, this.DEST_LOC as DEST_LOC0_, this.DOC_INT_NO as DOC_INT_NO0_, this.MERGE_CASE_FILE as MERGE_C12_0_, this.REMARK as REMARK0_, this.LAST_UPDATE_DATE as LAST_UP14_0_, this.OBJECT_TYPE as OBJECT_15_0_, this.OBJECT_DTL as OBJECT_DTL0_ from FILE_MOVEMENT_VIEW this where (this.CASE_COURT_SYS=? and this.CASE_TYPE=? and this.CASE_SER_NO=? and this.CASE_YR=?) ) where rownum <= ?
16:17:59,228 DEBUG [com.company.dao.FileMovementView] ******* yumyumyum = 42
16:17:59,228 DEBUG [com.company.dao.FileMovementView] ******* fileMovementViewByCaseNo.size() = 42