Skip to content

IN query condition

xjodoin edited this page Mar 14, 2013 · 2 revisions

The IN condition can receive collection in parameter or a enumeration.

Enumeration:

Entity from = from(Entity.class);
where(from.getCode()).in("Joe", "Bob");
Query<Entity> select = select(from);

Collection:

List<String> codes = new ArrayList<String>();
codes.add("Joe");
codes.add("Bob");

Entity from = from(Entity.class);
where(from.getCode()).in(codes);
Query<Entity> select = select(from);

IN condition can also receive SubQuery In parameter

Entity subQuery = from(Entity.class);
Query<String> allCodes = select(subQuery.getCode());

Entity from = from(Entity.class);
where(from.getCode()).in(allCodes);
Query<Entity> select = select(from);
Clone this wiki locally