您好,欢迎访问三七文档
当前位置:首页 > IT计算机/网络 > 数据库 > ofbiz对数据库的操作
1.*功能:取得demo信息列表2.*@paramrequest3.*@paramresponse4.*@return5.*/6.publicstaticStringgetDemoList(HttpServletRequestrequest,HttpServletResponseresponse)7.{8.//取得数据源对象9.//GenericDelegatordelegator=(GenericDelegator)request.getAttribute(default);10.GenericDelegatordelegator=GenericDelegator.getGenericDelegator(default);11.ListreturnList=null;12.try13.{14.//取得所有数据15.returnList=delegator.findAll(Demo);//select*fromdemo16.delegator.findByAnd(Demo,UtilMisc.toMap(demoId,1,demoName,a));17.//select*fromdemowheredomo_id='1'anddemo_name='a'18.delegator.findByOr(Demo,UtilMisc.toMap(demoId,1,demoName,a));19.delegator.findByPrimaryKey(Demo,UtilMisc.toMap(demoId,1));20.}21.catch(GenericEntityExceptionex){22.Debug.log(ex);23.request.setAttribute(myException,ex);24.StringstrExInfo=ExceptionUtil.getStackTraceInfo(ex,查询失败!);25.request.setAttribute(SiteDefs.ERROR_MESSAGE,strExInfo);26.returnerror;27.}28.//将数据放入缓存中,在页面可以拿到29.request.setAttribute(returnList,returnList);30.//根据返回值确定在那一个页面展示,起页面导向的作用31.returnsuccess;32.}33.34.35.publicstaticStringgetDemoYanShi(HttpServletRequestrequest,HttpServletResponseresponse)36.{37.//取得数据源对象38.//GenericDelegatordelegator=(GenericDelegator)request.getAttribute(default);39.GenericDelegatordelegator=GenericDelegator.getGenericDelegator(default);40.ListreturnList=null;41.try42.{43.//取得所有数据44.returnList=delegator.findAll(Demo);45.delegator.findByAnd(Demo,UtilMisc.toMap(demoId,1,demoName,a));46.delegator.findByOr(Demo,UtilMisc.toMap(demoId,1,demoName,a));47.}48.catch(GenericEntityExceptionex){49.Debug.log(ex);50.request.setAttribute(myException,ex);51.StringstrExInfo=ExceptionUtil.getStackTraceInfo(ex,查询失败!);52.request.setAttribute(SiteDefs.ERROR_MESSAGE,strExInfo);53.returnerror;54.}55.//将数据放入缓存中,在页面可以拿到56.request.setAttribute(returnList,returnList);57.//根据返回值确定在那一个页面展示,起页面导向的作用58.Stringtype=suce;59.if(type==shixisheng)60.returnshixisheng;61.else62.returnsuccess;63.}
本文标题:ofbiz对数据库的操作
链接地址:https://www.777doc.com/doc-2890186 .html