软件编程
位置:首页>> 软件编程>> java编程>> Mybatis使用JSONObject接收数据库查询的方法

Mybatis使用JSONObject接收数据库查询的方法

作者:yddwinter  发布时间:2023-01-17 05:10:43 

标签:Mybatis,JSONObject,数据库查询

1. mapper.xml设置resultType


resultType="com.alibaba.fastjson.JSONObject"

Mybatis使用JSONObject接收数据库查询的方法

2. Mapper.java使用JSONObject接收


// 查询isvalid=1的数据
   JSONObject selectValidBom(String parentsCode);

3. 测试


// 测试查询BOM的sql语句
   @Test()
   public void testSelectValidBom() {
       JSONObject validBom = ebomService.getValidBom("YZCL-80051-0010");
       System.out.println("结果:" + validBom);
       System.out.println("主键:" + validBom.getString("AutoID"));
       System.out.println("版本号:" + validBom.getIntValue("bbh"));
   }

输出结果:

Mybatis使用JSONObject接收数据库查询的方法

来源:https://www.cnblogs.com/yddwinter/p/15747738.html

0
投稿

猜你喜欢

手机版 软件编程 asp之家 www.aspxhome.com