问题
I have a model class that has an id per record. And I have a list of id's that I want to search from that table.
Do I need to build a SQL statement dynamically and pass it to the Finder object or is there a better way of doing it?
回答1:
Try to build a query using Expr.in(String propertyName, Collection<?> values)
Other options are : Expr.in(String propertyName, Object[] values)
or Expr.in(String propertyName, Query<?> subQuery)
API reference.
来源:https://stackoverflow.com/questions/16387727/how-do-i-find-all-records-matching-a-list-of-ids-in-ebean-and-play-framework