How to create a multi-column "in" predicate?

53 views
Skip to first unread message

buck...@gmail.com

unread,
Feb 24, 2023, 1:38:46 PM2/24/23
to Ebean ORM
I need to select a list of persons matching a given list of (firstName, lastName) tuple values.  Is there a way to do it in a single statement in ebean?

```java
class Person {
  String firstName;
  String lastName;
  int age;
  // other fields
}
```

The easy but slow way is to find the persons one at a time with multiple trips to the database.

Thanks,
Buck
Message has been deleted

Rob Bygrave

unread,
Mar 14, 2023, 11:52:44 PM3/14/23
to eb...@googlegroups.com
Sorry, the email went into my spam folder again!!

Anyway, the answer is "sort of".

Ebean has io.ebean.Pairs which is logically close to what we'd be looking for here but noting that the implementation of "Pairs" is limited to 2 properties (so firstName + lastName is fine) and the implementation currently uses db varchar concatenation. That is kind of ok IF that is what you want and especially if there is an expression/formula index to match.

However, using Pairs isn't ok if we don't want to use the db varchar concatenation implementation and instead want the more general multi-column IN clause (which is what I believe you would be expecting and looking for). 

Ideally what we should add to ebean is a more general solution that supports more than 2 properties and uses multi-column IN clause.


Cheers, Rob.

--

---
You received this message because you are subscribed to the Google Groups "Ebean ORM" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ebean+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ebean/2e398aea-9698-44b6-a652-e93dcd808b9dn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages