Query fails in hibernate 5.2
See original GitHub issueAfter upgrading hibernate to 5.2.14, the following example query fails:
select {product.*} from product...
with the following eror:
org.postgresql.util.PSQLException: ERROR: syntax error at or near "{"
From my investigation, HibernateHandler doesn’t set entity alias/type on query because it is expecting it to be of type HibernateQuery, but instead it’s a NativeQueryImpl type, thus silently skipping (should log?):
public void addEntity(Query query, String alias, Class<?> type) {
if (query instanceof HibernateQuery) {
org.hibernate.Query hibernateQuery = ((HibernateQuery) query).getHibernateQuery();
if (hibernateQuery instanceof SQLQuery) {
((SQLQuery) hibernateQuery).addEntity(alias, type);
}
}
}
Proposed solution:
Check also if query instanceof NativeQuery
. Same for other methods inside HibernateHandler.
Note that hibernate SQLQuery is:
Deprecated (since 5.2) use NativeQuery instead.
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (8 by maintainers)
Top Results From Across the Web
Hibernate 5.2.10 NoSuchMethodError error while execute HQL
I am getting error like this when I call my HQL get method. I'm using Hibernate 5.2.10 version. My application server is Wildfly...
Read more >Hibernate ORM 5.2.18.Final User Guide - Red Hat on GitHub
Mapping the entity to a SQL query; 2.5.9. ... Hibernate Query API. 15.4.1. ... Hibernate 5.2 and later versions require at least Java...
Read more >Anyone else get a syntax error when using the updated code ...
and tried out the Update for Hibernate 5.2+ listed in the Teacher's Notes. I got a syntax error on the method invocation session....
Read more >2084 (Upgrade to Hibernate 5.2) - BASE
It is considered an error to call this method on a session which was not opened by supplying the JDBC connection and an...
Read more >Issue navigator - Hibernate JIRA - Atlassian
1... javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Error calling CallableStatement.getMoreResults 2 at org.hibernate.jpa ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
We’ve not pushed for Hibernate 5.2 yet but thanks a lot for reporting. Would seem this is easy to miss. First need to get some things going regarding Querydsl 5.
Querydsl is now compatible with hibernate 5.