0

I'm looking to select using two conditions in LambdaJ select, i've tried to use and() function but i can't figure out how to use it.the above code selects using one condition. how i could add another condition?

select(filteredPB,     having(on(Table.class).getId(), IsEqual.equalTo(key))) 
geogeek
  • 1,274
  • 3
  • 25
  • 42
  • It isn't very clear what you want to do. It seems you want to select items with an id equal to some key. But then also some other condition which you have not specifically mentioned? – Tony Jan 08 '15 at 09:03
  • edit made ,yes i wanna add another condition but i don't know how to do it – geogeek Jan 08 '15 at 09:07
  • 1
    Can you just nest, like this: `select( select(filteredPB, having(on(Table.class).getId(), IsEqual.equalTo(key))), having(Condition2), IsEqual...)`? select returns an iterable, so it _might_ work. – Tony Jan 08 '15 at 09:17
  • 1
    and(having(...), having(...)) – HellishHeat Jan 09 '15 at 01:34
  • @geogeek You should self-answer this question if you have a solution for it. – heenenee Jan 01 '16 at 06:36

1 Answers1

0

You could use Matchers.allOf for ANDs and Matchers.anyOf for ORs. Like this:

select(filteredPB, Matchers.allOf(
    having(on(Table.class).getId(), IsEqual.equalTo(key)),
    having(on(Table.class).getValue(), IsEqual.equalTo(value))
))