Reputation: 3110
I would like to return an array from an annotation based Mybatis mapper to avoid the memory overhead of boxed primitives. Is this possible?
I tried
@Select("select id from some_table")
public long[] selectIds();
with no luck.
Upvotes: 2
Views: 1736
Reputation: 125
MyBatis mapper can return array of Object,but not array of primitives
please see the example below:-
@Results({
@Result(property = "id", column = "id"),
@Result(property = "name", column = "name"),
@Result(property = "staffNumber", column = "staff_number")
})
@Select("select * from USERS")
User[] finduserArr();
Upvotes: 1
Reputation: 7569
Try adding @MapKey annotation. It produces a Map with id as key and a Hashmap (key = column Name, value = value) as value
Check nested mybatis map for further reference
Upvotes: 0