Ebean run native SQL queries with list of arguments
سؤال
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?
المحلول
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);
لا تنتمي إلى StackOverflow