如何在 hibernate 的内部查询中添加 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();
Run Code Online (Sandbox Code Playgroud)
我对您的查询做了一些更正:1.qt。suQuotation 有一个空格,我已经删除了 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();
Run Code Online (Sandbox Code Playgroud)
告诉我,如果可以的话
如果不行,请在此处发布错误,并检查您是否已将您的类放入 hibernate 映射文件中
| 归档时间: |
|
| 查看次数: |
16703 次 |
| 最近记录: |