atitit.新增编辑功能 跟orm的实现 attilax p31
来源:互联网 发布:java中源代码什么意思 编辑:程序博客网 时间:2024/06/05 05:53
atitit.新增编辑功能 跟orm的实现 attilax p31
1. 流程的实现 1
2. view的实现(dwr) 1
3. 获取表结构 1
4. grep filt req params 2
5. 转换成个atiorm map 3
6. 转换成个sql 4
7. 参考 4
1. 流程的实现
传统的orm的问题::不能动态insert... myeclipse到是容易的...要是eclispe走麻烦的兰...
在说,cant 动态添加字段,要同步修改domain文件...
所以,atiorm 使用表格结构来做orm不走ok兰???
获得req参数,组成对象...
过滤table不存在的字段...
转换为sql
add/update的实现不在ui上指定,使用模式,,通过oid来有判断力的add还是edit
作者:: 老哇的爪子 Attilax 艾龙, EMAIL:1466519819@qq.com
转载请注明来源: http://blog.csdn.net/attilax
2. view的实现(dwr)
隐藏控件_meth=orm
在的控件都是对象 fld
3. 获取表结构
位置:wechat4propty
public class DbX {
/**
@author attilax 老哇的爪子
@since p31 j_o_53
*/
public static List getColsList(Connection con, String table) {
List li=new ArrayList();
// TODO Auto-generated method stub
String tableName=table;
DatabaseMetaData dbmd;
try {
dbmd = con.getMetaData();
} catch (SQLException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
throw new RuntimeException(e2);
}
ResultSet rs;
try {
rs = dbmd.getColumns(con.getCatalog(), "%", tableName, null);
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
throw new RuntimeException(e1);
}
try {
while(rs.next()) {
String columnName = rs.getString("COLUMN_NAME");
li.add(columnName);
// String columnType = rs.getString("TYPE_NAME");
// int datasize = rs.getInt("COLUMN_SIZE");
// int digits = rs.getInt("DECIMAL_DIGITS");
// int nullable = rs.getInt("NULLABLE");
// System.out.println(columnName+" "+columnType+" "+datasize+" "+digits+" "+
// nullable);
// }
}
} catch (SQLException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
return li;
}
4. grep filt req params
/**
* @author attilax 老哇的爪子
* @since p31 h_43_3
*/
private Map filtField(Map m) {
JSONObject metadata = JSONObject.fromObject(m.get("_metadata"));
String table = (String) metadata.get("table");
Connection conn = (Connection) core.retry3(new Closure() {
@Override
public Object execute(Object arg0) throws Exception {
Connection conn2 = AaaCfg.IocX.getBean(Connection.class);
boolean b = DbX.checkConn(conn2);
if (b)
return conn2;
else
throw new RuntimeException(" conn is close maybe ");
}
}, new errEventProcess() {
@Override
public Object execute(Object arg0) throws Exception {
// TODO Auto-generated method stub
return null;
}
}, "c:\\getconn");
List li = DbX.getColsList(conn, table);
Map m2 = Mapx.grep(m, li);
return m2;
}
5. 转换成个atiorm map
/**
* @author attilax 老哇的爪子
* @since p31 h_37_2
*/
protected Map convert2atiormMap(Object arg0) {
Map m = (Map) arg0;
Map m_filted_fld = filtField(m);
JSONObject metadata = JSONObject.fromObject(m.get("_metadata"));
Map m2 = new HashMap();
m2.put("datatype", metadata.get("table"));
m2.put("op", metadata.get("op"));
m2.put("field", m_filted_fld);
return m2;
}
6. 转换成个sql
Command.reg("orm", new Closure2() {
@Override
public Object execute(Object arg0) {
Map m2 = convert2atiormMap(m);
Object sql = new OrmX().convert2sql(core.toJsonStrO88(m2));
7. 参考
java 获取表结构 - HouYing - 博客频道 - CSDN.NET.htm
- atitit.新增编辑功能 跟orm的实现 attilax p31
- Atitit.注册跟个登录功能的实现attilax总结obo
- atitit.orm的缺点与orm框架市场占有率,选型attilax总结
- Atitit.二维码功能的设计实践 attilax 总结
- Atitit 修改密码的功能流程设计 attilax总结
- atitit.词法分析的实现token attilax总结
- atitit.loading的设计与实现控件选型attilax 总结
- atitit.loading的设计与实现控件选型attilax 总结
- ATITIT.翻译模块的设计与实现 api attilax 总结
- Atitit.异步的实现模式attilax大总结
- Atitit 通用接口的设计与实现attilax 总结
- Atitit 通用接口的设计与实现attilax 总结
- Atitit. 状态模式(State)attilax 总结 跟个策 略模式的区别
- Atitit orm优缺点 Hinaernate mybatis 区别。attilax总结
- Atitit.软件开发的非功能性需求attilax 总结At
- Atitit.常用分区api的attilax总结
- Atitit. Derby的使用总结attilax
- atitit.attilax的软件 架构 理念.docx
- 【bzoj3064】【Tyvj 1518 CPU监控】
- pat1013
- 工厂模式
- 指针函数与函数指针的区别
- hadoop--自动化脚本-- 自动给奴隶机器发送hadoop安装包
- atitit.新增编辑功能 跟orm的实现 attilax p31
- 锁与隔离级别的关系
- ubuntu配置vnc(ubuntu12.04版本亲自验证过)
- CF(#294 div2):D. A and B and Interesting Substrings
- iOS开发之计算应用启动次数
- 遍历二叉树的各种操作(非递归遍历)
- 随意牌 个人电脑文档分类优化器 帮助文档
- How to Use MFC Tab Control in Developing VC++ Applications
- listview选中某一行,选中行高亮显示