如何在休眠内部查询中添加 setparameter() 方法?
我尝试这样做但已经有错误
这是我的代码
Query query=session.createQuery("select eq.euipmentName,eq.type from Euipment eq where eq.id in(select euipment from Quotation qt where qt. supQuotation=:ids)");
query.setParameter("ids",id);
list = (List<Euipment>)query.list();
我对您的查询做了一些更正:
1. qt. supQuotation有空格,我已经去掉了
2.你子查询中的euipment没有别名,我添加了qt
String hql =
"select eq.euipmentName,eq.type " +
" from Euipment eq " +
" where eq.id in (select qt.euipment from Quotation qt where qt.supQuotation = :ids)";
Query query = session.createQuery(hql);
query.setParameter("ids",id);
list = (List<Euipment>)query.list();
告诉我,如果可以的话
如果不行,请在此处发布错误,并检查您是否已将您的类放入 hibernate 映射文件中
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)