mybatis中collection嵌套collection引发的bug解决方法

作者:袖梨 2020-12-01

本篇文章小编给大家分享一下mybatis中collection嵌套collection引发的bug解决方法,文章代码介绍的很详细,小编觉得挺不错的,现在分享给大家供大家参考,有需要的小伙伴们可以来看看。


  
  
  
 
    
  

 

  
  
  
  
  
 
    
 

 

  
  
  
  

 

  p.Id, p.Name, p.SurName,
 
 

  c.Id as c_Id, c.ParentId as c_ParentId, c.Name as c_Name, c.SurName as c_Surname, c.Age as c_Age,

 

  t.Id as t_Id, t.Name as t_Name, t.Color as t_Color
 
 

表面来看没有任何问题 实际 查询的child对象中的toys一直是空

类关系介绍:

Parent类有属性ArrayList children

Child类有属性ArrayList toys

Toy是一个普通的类

原因在于:

  

columnPrefix配置的是t_实际mybatis处理后是 c_t_

解决办法:

只需要修改 sql 修改前缀为 c_t_ 即可


  t.Id as c_t_Id, t.Name as c_t_Name, t.Color as c_t_Color
 

相关文章

精彩推荐