|
定义Action返回值为Table类型Action的返回值类型,在其对应的java方法中直接指定即可。
例如:- public static Table select() {
- Table table = KSQL.select("select ER_WPXX.* from ER_WPXX ER_WPXX", null, "/erp/buy/data", null);
- table.getProperties().put(Table.PROP_NAME_ROWID, "ER_WPXX");
- return table;
- }
[color=rgb(51, 102, 153) !important]复制代码
|
在java中返回Table类型1、使用KSQL.select方法
例如- import com.justep.system.data.KSQL;
- String query = "select t.sOrgFID, t.sOrgFName, t.sOrgName from SA_ResourceControl t where t.sResourceID=:resource and t.sTypeID=:type";
- HashMap<String, Object> params = new HashMap<String, Object>();
- params.put("type", typeID);
- params.put("resource", resourceID);
- Table table = KSQL.select(query, params, "/system/data", null);
[color=rgb(51, 102, 153) !important]复制代码
2、使用SQL.select方法
例如- import com.justep.system.data.SQL;
- String oracle = "SELECT RPRODUCTID , RPRODUCTNAME , (SELECT RCATEGORYNAME FROM DEMO_REPORTPRODUCTCATEGORY WHERE DEMO_REPORTPRODUCTCATEGORY.RCATEGORYID = DEMO_REPORTPRODUCTS.RCATEGORYID) AS RCATEGORYNAME , (SELECT RCOMPANYNAME FROM DEMO_REPORTSUPPLIERS WHERE DEMO_REPORTSUPPLIERS.RSUPPLIERID = DEMO_REPORTPRODUCTS.RSUPPLIERID)AS RCOMPANYNAME, RQUANTITYPERUNIT,RUNITPRICE,RUNITSINSTOCK FROM DEMO_REPORTPRODUCTS";
- String mssql = "SELECT RPRODUCTID, RPRODUCTNAME, (SELECT RCATEGORYNAME FROM DEMO_REPORTPRODUCTCATEGORY WHERE DEMO_REPORTPRODUCTCATEGORY.RCATEGORYID = DEMO_REPORTPRODUCTS.RCATEGORYID) AS RCATEGORYNAME , (SELECT RCOMPANYNAME FROM DEMO_REPORTSUPPLIERS WHERE DEMO_REPORTSUPPLIERS.RSUPPLIERID = DEMO_REPORTPRODUCTS.RSUPPLIERID)AS RCOMPANYNAME, RQUANTITYPERUNIT,RUNITPRICE,RUNITSINSTOCK FROM DEMO_REPORTPRODUCTS";
- HashMap<String,String> sqlMap = new HashMap<String,String>();
- sqlMap.put(SQL.DEFAULT_DB_NAME,mssql);
- sqlMap.put(DatabaseProduct.ORACLE.name(),oracle);
- sqlMap.put(DatabaseProduct.MSSQL.name(),mssql);
- sqlMap.put(DatabaseProduct.KINGBASE.name(),oracle);
- sqlMap.put(DatabaseProduct.SYBASE.name(),mssql);
- sqlMap.put(DatabaseProduct.DB2.name(),oracle);
- sqlMap.put(DatabaseProduct.MYSQL.name(),mssql);
- return SQL.select(sqlMap,null,"/demo/report/data");
[color=rgb(51, 102, 153) !important]复制代码
|
3、使用BizUtils.resultSet2Table方法
例如- import com.justep.system.util.BizUtils;
- Connection conn = ModelUtils.getConnection("/x5demo/rich/data");
- Statement exeistStmt = conn.createStatement();
- String sql = "select fGoodsCode,fGoodsName from X5_Goods";
- ResultSet rs = exeistStmt.executeQuery(sql);
- Table table = BizUtils.resultSet2Table(rs, (Model)null);
[color=rgb(51, 102, 153) !important]复制代码
問題:
1.
總共有三種方法。為何只有第一個方法需要設置table的主鍵,具體有何用途?
->table.getProperties().put(Table.PROP_NAME_ROWID, "ER_WPXX");
2.
為何其他方法都不需要加這句?
|
|