question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Query fails in hibernate 5.2

See original GitHub issue

After 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:closed
  • Created 6 years ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
Shredder121commented, Mar 6, 2018

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.

0reactions
johnktimscommented, May 30, 2020

Querydsl is now compatible with hibernate 5.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found