Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将参数数组设置为hibernate查询语言_Hibernate_Hql - Fatal编程技术网

将参数数组设置为hibernate查询语言

将参数数组设置为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());

目前,查询采用单个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());

    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作为参数传递