Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Mybatis注释映射程序能否返回数组?_Java_Arrays_Select_Mybatis - Fatal编程技术网

Java Mybatis注释映射程序能否返回数组?

Java Mybatis注释映射程序能否返回数组?,java,arrays,select,mybatis,Java,Arrays,Select,Mybatis,我想从基于注释的Mybatis映射器返回一个数组,以避免装箱原语的内存开销。这可能吗 我试过了 @Select("select id from some_table") public long[] selectIds(); 运气不好。尝试添加@MapKey注释。它生成一个id为键、Hashmap键=列名、值=值作为值的映射 查看更多参考资料尝试添加@MapKey注释。它生成一个id为键、Hashmap键=列名、值=值作为值的映射 查看更多参考资料可以从3.1版开始使用。尝试使用3.1.1。从3

我想从基于注释的Mybatis映射器返回一个数组,以避免装箱原语的内存开销。这可能吗

我试过了

@Select("select id from some_table")
public long[] selectIds();

运气不好。

尝试添加@MapKey注释。它生成一个id为键、Hashmap键=列名、值=值作为值的映射


查看更多参考资料

尝试添加@MapKey注释。它生成一个id为键、Hashmap键=列名、值=值作为值的映射


查看更多参考资料

可以从3.1版开始使用。尝试使用3.1.1。

从3.1版开始就可以了。尝试使用3.1.1。

MyBatis mapper可以返回对象数组,但不能返回原语数组

请参见以下示例:-

@Results({
    @Result(property = "id", column = "id"),
    @Result(property = "name", column = "name"),
    @Result(property = "staffNumber", column = "staff_number")
  })    
@Select("select * from USERS")
User[] finduserArr();
MyBatis mapper可以返回对象数组,但不能返回原语数组

请参见以下示例:-

@Results({
    @Result(property = "id", column = "id"),
    @Result(property = "name", column = "name"),
    @Result(property = "staffNumber", column = "staff_number")
  })    
@Select("select * from USERS")
User[] finduserArr();