mybatis sql出现查询的返回值为object类型问题

原来sql是这么写的 

select * from 

(select e.keyid,e.trade_sub_id,e.product_id,e.product_name,a.owenauth_userid from 

<!-- e --> (select id as keyid,trade_sub_id,product_id,product_name from ente_product where sysdate() between start_date and end_date  and ente_id=#{ente_id} ) e 

<!-- a --> left join (select ifnull(owenauth_userid,'') as owenauth_userid,trade_sub_id from ent_total_authno where isauth='1' and sysdate() between auth_start_date and auth_end_date

and owenauth_userid=#{owenauth_userid}

) a 

<!-- pro --> on e.trade_sub_id=a.trade_sub_id group by e.keyid) pro 

left join 

<!-- goo -->(select distinct g.id as gid,g.inurl,ifnull(p.mainpicurl,'') as mainpicurl from goods_mainpic p right join goods g on g.id=p.goodsid group by g.id) goo 

on goo.gid=pro.product_id

返回的值中owenauth_userid  为object类型 且取值不正确, 后来把红色改为owenauth_userid 就得到正常值了,原因是owenauth_userid在数据库是bigint类型,所以应该写成ifnull(owenauth_userid ,0) as owenauth_userid 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
MyBatis 中进行批量更新操作,可以使用 `SqlSession` 的 `update` 方法来执行。是需要注意的是,批量更新操作的返回值是一个整数,表示被修改的记录数。 具体的步骤如下: 1. 获取 `SqlSession` 对象,可以通过 `SqlSessionFactory` 创建。 2. 创建一个包含多个更新操作的 `List`,每个更新操作可以使用相同的 SQL 语句或不同的 SQL 语句。 3. 使用 `SqlSession` 的 `update` 方法执行批量更新操作,并将包含多个更新操作的 `List` 作为参数传入。 4. 提交事务,可以通过 `SqlSession` 的 `commit` 方法来提交,或者在配置文件中设置自动提交。 5. 获取返回值,批量更新操作的返回值是一个整数,表示被修改的记录数。 示例代码如下: ```java SqlSession sqlSession = sqlSessionFactory.openSession(); try { List<MyObject> myObjects = new ArrayList<>(); // 添加多个要更新的对象到 myObjects 列表中 int affectedRows = sqlSession.update("updateStatementId", myObjects); // updateStatementId 是定义在 Mapper XML 文件中的更新 SQL 语句的 id sqlSession.commit(); System.out.println("Affected Rows: " + affectedRows); } finally { sqlSession.close(); } ``` 需要注意的是,批量更新操作的返回值是所有更新操作影响的记录数之和,并不会返回每个具体操作的结果。如果需要获取每个具体操作的结果,可以考虑在执行批量更新之前,先进行单独的批量查询操作来获取相关数据
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值