将参数数组设置为hibernate查询语言
目前,查询采用单个reportID来返回结果。现在,如果我想传递多个reportid并在一次对数据库的调用中返回o/p,我该怎么做将参数数组设置为hibernate查询语言,hibernate,hql,Hibernate,Hql,目前,查询采用单个reportID来返回结果。现在,如果我想传递多个reportid并在一次对数据库的调用中返回o/p,我该怎么做 String queryText = "from com.abc.domain.bcd.Report report where report.reportID in :reportId"; Query query = SessionFactory.getCurrentSession().createQuery(queryText.toString());
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();
我试着以arrayList的身份通过,但没有成功。得到下面的错误
List<String> reportID= new ArrayList<String>();
reportID.add("aaa");
reportID.add("bbb");
List reportID=new ArrayList();
报告ID.添加(“aaa”);
报告ID.添加(“bbb”);
java.util.ArrayList与java.lang.String不兼容试试这个
query.setParameterList("reportID", new Object[]{"aaa","bbb"});
如何将字符串[]reportID作为参数传递