简体   繁体   English

HQL查询上的HashSet排序期间的休眠异常:org.hibernate.exception.SQLGrammarException:无法使用滚动执行查询

[英]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没有ClienteErrIndirizzo 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.

相关问题 嵌套的异常是org.hibernate.exception.SQLGrammarException:无法执行查询 - nested exception is org.hibernate.exception.SQLGrammarException: could not execute query 如何解决 org.hibernate.exception.SQLGrammarException: 无法执行查询 - How to solve org.hibernate.exception.SQLGrammarException: could not execute query RuntimeException:org.hibernate.exception.SQLGrammarException:无法执行查询 - RuntimeException: org.hibernate.exception.SQLGrammarException: could not execute query org.hibernate.exception.SQLGrammarException:无法执行查询 - org.hibernate.exception.SQLGrammarException: could not execute query org.hibernate.exception.SQLGrammarException:无法再次执行查询 - org.hibernate.exception.SQLGrammarException: could not execute query again 嵌套的异常是org.hibernate.exception.SQLGrammarException:无法执行查询-添加了“ 0_” - nested exception is org.hibernate.exception.SQLGrammarException: could not execute query - “0_” added javax.persistence.PersistenceException:org.hibernate.exception.SQLGrammarException:无法执行查询 - javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: 无法使用 heroku PostgreSQL 执行查询 - javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query with heroku PostgreSQL org.hibernate.exception.SQLGrammarException:无法执行语句 - org.hibernate.exception.SQLGrammarException: could not execute statement org.hibernate.exception.SQLGrammarException:无法执行JDBC批更新 - org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM