[英]Hibernate exception during order by with HashSet on HQL query: org.hibernate.exception.SQLGrammarException: could not execute query using scroll
I'm trying to get a list of items ordered through an HQL query . 我正在尝试获取通过HQL查询排序的项目的列表。 The problem is that the sort is done on a HashSet of objects(orber by ab.clienti.errIndirizzos, where errIndirizzos is HashSet set on class
Clienti
), and when I try to do the sorting hibernate returns an exception 问题是排序是在对象的HashSet上完成的(由ab.clienti.errIndirizzos处理,其中errIndirizzos是在
Clienti
类上设置的HashSet ),并且当我尝试进行排序时,休眠会返回异常
Clienti.java: Clienti.java:
public class Cliente implements java.io.Serializable {
//declaration var
private Set errIndirizzos = new HashSet(0);`
.....
}
Cliente.hbm.xml Cliente.hbm.xml
<set name="errIndirizzos" inverse="true" >
<key>
<column name="ID_CLIENTE" precision="18" scale="0" />
</key>
<one-to-many class="ErrIndirizzo" />
</set>
where table ERR_INDIRIZZO and CLIENTE have unique key "ID_CLIENTE"
其中表ERR_INDIRIZZO和CLIENTE具有唯一键
"ID_CLIENTE"
HQL Query order by: HQL查询顺序:
order by le.cliente.errIndirizzos
where le
is another table that contain Clienti 其中
le
是包含Clienti的另一个表
LetteraCliente.java LetteraCliente.java
public class Letteracliente implements java.io.Serializable {
.....
private Cliente cliente
......
}
letteraCliente.hbm.xml letteraCliente.hbm.xml
<one-to-one name="cliente" class="it.allianz.images.bean.postaMassiva.Cliente" constrained="true"></one-to-one>
Error: 错误:
org.hibernate.exception.SQLGrammarException: could not execute query using scroll
Any suggestion? 有什么建议吗? thanks in advance
提前致谢
Try using implicit joins instead: 尝试改用隐式联接:
select distinct le
from Letteracliente le
inner join le.cliente c
inner join c.errIndirizzos e
order by e.id
Using INNER JOIN will also filter all Letteracliente
without Cliente
or ErrIndirizzo
. 使用INNER JOIN也会过滤所有
Letteracliente
没有Cliente
或ErrIndirizzo
。 You can choose some other property for the ORDER BY, if the id
is not what you wanted. 如果
id
不是您想要的,则可以为ORDER BY选择其他属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.