我用的是SSH框架
存储过程是这样的
CREATE OR REPLACE PROCEDURE LIMING_ZZJHQR (sdt DATE,
  edt DATE,
  m_workshop  string,
  m_gd  string,
  workid string,
  inbuild string,
  m_xb string,
  ok string,
  ifbc string,
  RESULTSET OUT TEST_ZZJHQR.testresultset
)
ASbegin
open RESULTSET for SELECT rwfpb.kind,
         rwfpb.rwh,
         rwfpb.xb,
         rwfpb.gzh,
         rwfpb.pzrw,
         rwfpb.pzdt,
         rwfpb.dhdw,
         rwfpb.num,
         rwfpb.unit,
         rwfpb.workshop,
         rwfpb.plan,
         rwfpb.fnote,
         rwfpb.rwtype,
         rwfpb.commitdt,
         rwfpb.inorout,
         rwfpb.zzjhrq,
         rwfpb.zzjh,
         rwfpb.gzname,
         rwfpb.section,
         rwfpb.weekplan,
         rwfpb.setok ,
        (select sum(coalesce(gxmxb.djde,0) *coalesce(ljmxb.zjnum,0) )/60 from gxmxb,ljmxb where gxmxb.rwh =ljmxb.rwh and gxmxb.gzh = ljmxb.gzh and gxmxb.jh =ljmxb.jh and gxmxb.rwh=rwfpb.rwh and gxmxb.gzh=rwfpb.gzh and de_lx in ('A','B','C')) as zde,
        (select sum(degs)/60 from operatorlist,mom30100,mom30101
        where mom30100.no = mom30101.no and  operatorlist.no = mom30101.no and
        operatorlist.seq = mom30101.seq and rwh=rwfpb.rwh and gzh=rwfpb.gzh and mom30100.type <>'2'  and delx in ('A','B','C') ) as ywgs,
        (select sum(degs)/60 from operatorlist,mom30100,mom30101 where mom30100.no = mom30101.no and  operatorlist.no = mom30101.no and
        operatorlist.seq = mom30101.seq and rwh=rwfpb.rwh and gzh=rwfpb.gzh and delx in ('A','B','C') and
        to_char(mom30101.sj,'yyyy-mm') = sdt) as dyywgs,
        rwfpb.fpdt,rwfpb.processdt,rwfpb.xlsj,
        rwfpb.CHECKDT,
        rwfpb.isquota,
        rwfpb.quotadt,JDYQ,
        intime, finishtime,
        rwfpb.ismaterial as qlbs,
        rwfpb.materialdt as qlsj,
        (select max( dzjbh) from xldzjgl
        where rwh=rwfpb.rwh and gzh= rwfpb.gzh and ='1' ) as dj,
        (select max( dzjbh) from xldzjgl
        where rwh=rwfpb.rwh and gzh= rwfpb.gzh and ='2' ) as zj ,
        cancelreason,ifbc,fcnew,drawno,ljgxh,repairdescription,
        (select case when count(*)>=1 then 1 else 0 end from t_lj_cl where rwh = rwfpb.rwh and gzh = rwfpb.gzh) as ifxl,
        (select case when count(*)>0 then 1 else 0 end from t_lj_cl where bz1 in ('4','7') and rwh = rwfpb.rwh and gzh = rwfpb.gzh) as cgj,
        buyreturn
        FROM rwfpb,xldjd
        WHERE rwfpb.rwh= xldjd.taskid(+) and rwfpb.gzh=xldjd.workid(+) and
        (coalesce(rwfpb.workshop,' ') like m_workshop||'%' ) AND
        coalesce(rwfpb.section,' ') like m_gd||'%'  and
        (rwfpb.gzh like workid||'%') AND
        (rwfpb.isfinish like inbuild ) AND
        to_char(rwfpb.pzdt,'yyyy-mm') >= sdt AND
        to_char(rwfpb.pzdt,'yyyy-mm') <= edt  and
        coalesce(rwfpb.xb,' ') like m_xb and rwfpb.pzrw in ('1') and
        COALESCE(zzjh,'0') like ok and
        (coalesce(ifbc,'0') like '0' or  (coalesce(ifbc,'0') like '1' and '1'=ifbc));
end;

解决方案 »

  1.   

    我想在ACTION里面调用存储过程得到一个LIST,该如何写呢
    HIBERNATE让SPRING托管了
    package com.king.krs.struts.action;import java.text.ParseException;
    import java.text.SimpleDateFormat;
    import java.util.Calendar;
    import java.util.Date;
    import java.util.List;import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;import org.apache.struts.Globals;
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionErrors;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    import org.apache.struts.action.ActionMessage;
    import org.apache.struts.action.ActionMessages;
    import org.hibernate.Query;
    import org.hibernate.Session;import org.springframework.context.ApplicationContext;
    import org.springframework.web.struts.ActionSupport;import DB.chStr;import com.king.krs.dao.impl.Rwfpb;
    import com.king.krs.dao.impl.RwfpbId;
    import com.king.krs.pojo.HibernateSessionFactory;
    import com.king.krs.pojo.TUser;
    import com.king.krs.service.IMom30100Service;
    import com.king.krs.service.IUserService;
    import com.king.krs.service.Irwglservice;
    import com.king.krs.struts.form.LoginForm;
    import com.king.krs.struts.form.Mom30100Form;
    import com.king.krs.struts.form.rwglForm;
    import com.king.krs.struts.form.rwglxsbForm;
    import com.king.krs.struts.form.zzjhqrForm;/** 
     * MyEclipse Struts
     * Creation date: 02-26-2011
     * 
     * XDoclet definition:
     * @struts.action path="/mom30100" name="mom30100Form" input="/form/mom30100.jsp" scope="request" validate="true"
     */
    public class zzjhqrAction extends ActionSupport {
    /*
     * Generated Methods
     */ /** 
     * Method execute
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return ActionForward
     */
    public ActionForward execute(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response) {
    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); ApplicationContext context = getWebApplicationContext();
    Irwglservice service = (Irwglservice)context.getBean("rwglservice");
    zzjhqrForm zzForm = (zzjhqrForm) form;// TODO Auto-generated method stub
    List resultList = null;
      String hsql = "from rwfpb where 1=1 ";
      String m_gzh = request.getParameter("gzh");
      String m_sdt =request.getParameter("spzdt");
      String m_ddt = request.getParameter("dpzdt");
      String m_zt = request.getParameter("radiobutton1");
      String m_qr = request.getParameter("radiobutton");
      String m_gbjh = request.getParameter("imbc");
      String workshop = request.getParameter("workshop");
      if (m_gzh !=null && m_gzh != ""){
       hsql = hsql + " and id.gzh like '"+m_gzh+"%'";
      }
      if (m_sdt !=null && m_sdt != "" && m_ddt !=null && m_ddt != ""){
      
    hsql = hsql + " and pzdt between to_date('"+m_sdt+"','yyyy-mm-dd') and to_date('"+m_ddt+"','yyyy-mm-dd')";
      }   resultList = service.getList(hsql);
      
    request.setAttribute("rwresultList", resultList);
    ActionForward forward = mapping.getInputForward();
    forward = mapping.findForward("success");


    return forward;
    }
    }
    这是我原来查询一个表的ACTION 我想在这里修改成调用存储过程得到一个LIST 有人回答下没 
    在线等 最好是不用JDBC的
      

  2.   


    String procSql = "{Call LIMING_ZZJHQR()}"; 
    SQLQuery query = getSession().createSQLQuery(procSql);
    return query.executeUpdate();
      

  3.   

    你这个我在ACTION里报错啊 我想得到一个LIST啊
      

  4.   

    List resultList = null;
    String procSql = "{Call LIMING_ZZJHQR()}"; 
      SQLQuery query = HibernateSessionFactory.getSession().createSQLQuery(procSql);
      resultList= query.list();
    我改成这样了
    执行这个 SQLQuery query = HibernateSessionFactory.getSession().createSQLQuery报错
      

  5.   

    %%%% Error Creating SessionFactory %%%%
    org.hibernate.HibernateException: /hibernate.cfg.xml not found
    at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:147)提示这个错误