您的位置:首页 > 编程语言 > Java开发

java类在clob表中使用json格式的存取

2016-03-17 11:58 1221 查看
    应用场景是把指令对象的实体类转化为jsonSting类型,存储到大字段表中,添加待办指令。在授权是根据id查询指令,用json反序列化
public void testSerializeObject() throws Exception{
MngTeller oper = new MngTeller();
oper.setIdTeller("003");
oper.setTellerType(RoleType.ADMIN);
oper.setTellerName("管理员");
oper.setDepartNo("00001");
oper.setPassword("123456");

MngContent mc = new MngContent();
//处理成jsonString类型,存入大字段content中
JSONObject object = JSONObject.fromObject(oper);
String str = object.toString();
mc.setContent(str);
mc = mngContentDao.addMngContent(mc);
System.out.println("------------------");
System.out.println("mc.getContent()=" + mc.getContent());
//根据id查找指令
MngContent mcc = mngContentDao.getMngContentById(mc.getIdContent());
System.out.println("----------------------");
System.out.println("mcc.getContent()=" + mcc.getContent());
//反序列化指令,由指令类调用。指令类存action和method,加oper2参数执行待办指令
MngTeller oper2 = (MngTeller) JSONObject.toBean(JSONObject.fromObject(mcc.getContent()), MngTeller.class);
System.out.println("-------------------------");
System.out.println("oper2.getTellerName()=" + oper2.getTellerName());
}


成java类,取类参数执行指令
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: