Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

ActiveObjects: select several items by ID

grundic
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 25, 2011

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!

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

3 votes
Answer accepted
grundic
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 25, 2011

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.

TAGS
AUG Leaders

Atlassian Community Events