Question

I need to use Ebean to run native SQL queries like this: http://www.avaje.org/static/javadoc/pub/com/avaje/ebean/SqlQuery.html

But how can I express 'not in' syntax to set parameter?

Was it helpful?

Solution

not in should work fine directly in the SqlQuery.

select col1, col2 from tbl where col3 not in ( :val1, :val2 )


sqlQuery.setParameter("val1", 7);
sqlQuery.setParameter("val2", 42);

You can also pass a list as a parameter:

select col1, col2 from tbl where col3 not in ( :valList )


sqlQuery.setParameter("valList", listOfValues);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top