UEP-自定义持久化类

时间:2022-07-06 06:56:05

HY-UEP提供了两种持久化方式:基于JPA的持久化机制和自定义持久化机制,JPA的持久化机制

比较符合现在的软件开发模式,支持各种主流数据库;自定义持久化时我们平台产品的特有持久化

机制的升级,在综合查询、大数据量处理以及快速开发方面比较有优势,两者各有千秋,业务开

发人员可根据自身项目情况和具体功能选择使用。

自定义持久化包括结果集和DBTool

--添加自定义持久化类

Propertier-UEP-开发平台-Add 生成xml文件

--DataSet下

  • Query DataSet Root:一项可配置查询结果集文件的路径
  • Proc DataSet Root:一项可配置存储过程结果集文件的路径
  • Proc Mapping Root:一项可配置存储过程映射的路径

--配置demo.xml(=framework.xml)

UEP-自定义持久化类

UEP-自定义持久化类

UEP-自定义持久化类

--action中AjaxDataSetAction

package com.haiyisoft.bill.other.action;

import java.math.BigDecimal;
import java.util.List; import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result; import com.haiyisoft.ep.framework.ui.struts2.action.AjaxAction;
import com.haiyisoft.ep.framework.ui.struts2.action.AjaxDataSetAction;
import com.haiyisoft.ep.common.model.QueryParamList;
import com.haiyisoft.ep.framework.ui.struts2.model.AjaxDataSetWrap;
import com.haiyisoft.ep.framework.ui.struts2.model.AjaxDataWrap;
import com.haiyisoft.ep.framework.bizservice.AutowireService;
import com.haiyisoft.ep.log.LogUtil;
import com.haiyisoft.entity.UepCustomer;
import com.haiyisoft.bill.component.service.TcService; /**
* UepCustomer维护
*
* @author LENOVO
*
* <p>Modification History:</p>
* <p>Date Author Description</p>
* <p>------------------------------------------------------------------</p>
* <p>2017-12-7 LENOVO 新建</p>
*/
@Namespace("/other")
@ParentPackage("framework-default")
@Action(value = "/uepCustomerDS", results = {@Result(name="input",location="uepCustomerDS.jsp")})
public class UepCustomerDSAction extends AjaxDataSetAction { private static final long serialVersionUID = 1L;
@AutowireService
private TcService tcService;
private AjaxDataSetWrap dataWrap = new AjaxDataSetWrap(); /**
*查询操作
*/
@Override
public void retrieve() {
Object[] params = new Object[1];
params[0] = new BigDecimal(4);
dataWrap.retrieve(params);
//结果集带参数
     //dataWrap.retrieve();
     //结果集不带参数
responseData.setAjaxDataWrap("dataWrap", dataWrap);
} /**
*初始化
*/
@Override
protected void initTreat() {
super.retrieveAfterInit = true ;
//dataWrap.setDsName("queryCustomer");
dataWrap.setDsName("queryCustomerById");
     //添加结果集
this.dataWrap.getPageInfo().setRowOfPage(15);
} @Override
public AjaxDataSetWrap getDataWrap() {
return dataWrap;
} public void setTcService(TcService tcService) {
this.tcService = tcService;
} public TcService getTcService() {
return tcService;
}
}

--jsp中name只能为数据库中的字段名

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/framework/include/pageset.jspa"%>
<script type="text/javascript" src="uepCustomerDS.js"></script>
<html>
<head>
<title>UepCustomer维护</title>
</head>
<body>
<hy:view>
<s:form action="uepCustomerDS">
<hy:layoutTable>
<hy:layoutArea>
<hy:ajaxgrid id="ajaxgrid" name="dataWrap" height="100%" width="100%"
queryfunc="retrieve()">
<hy:gridlineno title="序号" width="30" />
<hy:gridcheckbox name="checked" width="50" title="全选" />
<hy:gridfield name="ID" title="ID" width="100" regexpmessage="只能为数字"
maxlength="12" required="true" regexp="^\d*$" />
<hy:gridfield name="CUSTOMER_NAME" title="客户名称" width="100"
required="true" maxlength="64" />
<hy:gridfield name="REMARKS" title="备注" width="100" maxlength="128" /> </hy:ajaxgrid>
</hy:layoutArea>
</hy:layoutTable>
</s:form>
</hy:view>
</body>
</html>

--DBTool

 public void retrieve(){
/*QueryParamList params = getQueryParam("dataWrap");
List<UepContract> list = uepCustomerService.retrieve(params,
dataWrap.getPageInfo(), dateWrap.getSortOptions());
dataWrap.setDataList(list);
responseData.setAjaxDataWrap("dataWrap", dataWrap);*/ String sql = "select * from uep_customer";
List<Object> params = new ArrayList<Object>();
DBTool[] tool = new DBTool();
Reocrd[] records = tool.executeQuery(sql,params,dataWrap.getPageInfo());
//Record序列化成UepCostomer实体
List<UepCustomer> dataList = tool.executeQuery(UepCostomer.class,
sql,params,dataWrap.getPageInfo());
dataWrap.setDataList(dataList);
responseData.setAjaxDataWrap("dataWrap",dataWrap);
}