mybatis的resultType类如果是一个内部类,如何返回呢

外部类:

RechargeListVO

内部类:

Summary

类的写法如下:

@Data
@Accessors(chain = true)
public class RechargeListVO implements Serializable {

/**
*充值时间
*/
private String rechargeTime;

@Data
@Accessors(chain = true)
public static class Summary implements Serializable{
/**
* 充值汇总
*/
private BigDecimal rechargeSum;

}

}

在mybatis的xml文件中的resultType写法:

resultType:

<select id="countRecharge" resultType="com.iot.bos.model.vo.RechargeListVO$Summary">

 

总结:

由之前 ‘.’ 变成了 ‘$’

1. resultType 后面内部类用 $连接

2. 内部类必须static修饰

3. 内部类必须有空的构造方法

 

 


原文链接:https://blog.csdn.net/l848168/article/details/91451534

posted @ 2024-11-13 16:59  苹果芒  阅读(254)  评论(0)    收藏  举报