我想从基于注释的Mybatis映射器返回一个数组,以避免盒装基元的内存开销。这可能吗?
我试过
@Select("select id from some_table")
public long[] selectIds();
没有运气。
答案 0 :(得分:0)
从版本3.1开始。试试3.1.1。
答案 1 :(得分:0)
MyBatis映射器可以返回Object数组,但不能返回基元数组
请参阅以下示例: -
@Results({
@Result(property = "id", column = "id"),
@Result(property = "name", column = "name"),
@Result(property = "staffNumber", column = "staff_number")
})
@Select("select * from USERS")
User[] finduserArr();
答案 2 :(得分:-1)
尝试添加@MapKey注释。它生成一个ID为密钥的Map和一个Hashmap(key = column Name,value = value)作为值
检查nested mybatis map以获取进一步的参考资料