问题
Currently the query takes in a single reportID to return the results. Now if I want to pass multiple reportIDs and return the o/p in just 1 call to the DB, how do I do that?
String queryText = "from com.abc.domain.bcd.Report report where report.reportID in :reportId";
Query query = SessionFactory.getCurrentSession().createQuery(queryText.toString());
query.setParameter("reportID", reportId);
query.list();
I tried passing as an arrayList but no luck. Got the error below
List<String> reportID= new ArrayList<String>();
reportID.add("aaa");
reportID.add("bbb");
java.util.ArrayList incompatible with java.lang.String
回答1:
try this one
query.setParameterList("reportID", new Object[]{"aaa","bbb"});
来源:https://stackoverflow.com/questions/13512109/set-array-of-parameters-to-hibernate-query-language