java - Pass list of values on query parameter -


string hql = "select * mytable isactive in (:isactive)";         query query = session.createquery(hql);         query.setstring("school","");         query.setstring("isactive", "y");//working         query.setstring("isactive", "n");//working         query.setstring("isactive", "y","n"); // not working         query.setstring("isactive", "'y','n'"); // not working         return query.list(); 

i have no idea if code below should work, wondering if can pass list of values search string parameter there's no need me create queries ; 1 select data regardless of status , select active data.

use query.setparameterlist() pass in list parameter:

string hql = "select * mytable isactive in (:isactive)"; query query = session.createquery(hql); list<string> isactivelist = new arraylist<>(); isactivelist.add("y"); isactivelist.add("n"); query.setparameterlist("isactive", isactivelist); return query.list(); 

Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -