Hello!
I'm trying to get a bunch of items. I got a list of their IDs. How can I get'em?
I know, that there is a method
ao.get(MyClass.class, itemId)
But how to call for list? The only solution came to my mind is to implement
"WHERE ID IN [1,2,3,4,5]"
Got better idea?
Thanks in advance!
Community moderators have prevented the ability to post new answers.
Okay, the problem is that I could'n pass array to get method - java was complaining, that it can't resolve such a method.
Solution is to make a wrapper:
public Iterable<MyObject> getObjects(Integer... myObjectIds) { return Lists.newArrayList(ao.get(MyObject.class, myObjectIds)); }
And pass an array to this wrapper :)
Hope it would help someone.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.