Is there a shortcut in Play Framework / JPA to save building this query manually?
public List<User> getAllExceptThese(Collection<String> emails) {
checkArgument(!emails.isEmpty());
StringBuilder query = new StringBuilder("email not in (");
boolean first = true;
for (String email : emails) {
if (!first) {
query.append(", ");
}
first = false;
query.append("?");
}
query.append(")");
return findAll(query.toString(), emails.toArray());
}
I don’t know about Play-framework, but if it’s possible to create JPQL-queries, how about building a Query-object and using it to insert the collection instead…