org.hibernate.exception.SQLGrammarException: could not execute query

Hibernate JIRA | Philippe Chaléat | 8 years ago
  1. 0

    Trying to migrate a rather large app from Hibernate 2.1 to Hibernate, we face a blocking problem. With Hibernate 3, some of our queries generate invalid SQL. I found in the forum that this problem has been noticed by someone else (but no answer) : http://forum.hibernate.org/viewtopic.php?t=963196&highlight=join+ora00904 We manage to reproduce the problem with the following query. With Hibernate 2, mixing explicit and implicit joins produced an SQL query with all "theta style" joins at the end of the query. In Hibernate 3, ANSI and "theta style" are mixed, which Oracle doesn't like. HBM: select a.description, a.seller, b.item.description " + "from org.hibernate.auction.AuctionItem a inner join a.bids b [java] SQL: [java] select [java] auctionite0_.description as col_0_0_, [java] auctionite0_.seller as col_1_0_, [java] auctionite3_.description as col_2_0_, [java] user2_.id as id2_, [java] user2_.userName as userName2_, [java] user2_."password" as password3_2_, [java] user2_.email as email2_, [java] user2_.firstName as firstName2_, [java] user2_."initial" as initial6_2_, [java] user2_.lastName as lastName2_ [java] from [java] AuctionItem auctionite0_ [java] inner join [java] Bid bids1_ [java] on auctionite0_.id=bids1_.item, [java] AuctionItem auctionite3_ [java] inner join [java] AuctionUser user2_ [java] on auctionite0_.seller=user2_.id [java] where [java] bids1_.item=auctionite3_.id Erreur: [java] org.hibernate.exception.SQLGrammarException: could not execute query [java] at org.hibernate.exception.SQLStateConverter.convert(SQLStateCon verter.java:67) [java] at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExcep tionHelper.java:43) [java] at org.hibernate.loader.Loader.doList(Loader.java:2216) [java] at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java: 2104) [java] at org.hibernate.loader.Loader.list(Loader.java:2099) [java] at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:37 8) [java] at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslato rImpl.java:338) [java] at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryP lan.java:172) [java] at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121) [java] at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79) [java] at org.hibernate.auction.Main.testOracleJoins(Main.java:359)

    Hibernate JIRA | 8 years ago | Philippe Chaléat
    org.hibernate.exception.SQLGrammarException: could not execute query
  2. 0

    Trying to migrate a rather large app from Hibernate 2.1 to Hibernate, we face a blocking problem. With Hibernate 3, some of our queries generate invalid SQL. I found in the forum that this problem has been noticed by someone else (but no answer) : http://forum.hibernate.org/viewtopic.php?t=963196&highlight=join+ora00904 We manage to reproduce the problem with the following query. With Hibernate 2, mixing explicit and implicit joins produced an SQL query with all "theta style" joins at the end of the query. In Hibernate 3, ANSI and "theta style" are mixed, which Oracle doesn't like. HBM: select a.description, a.seller, b.item.description " + "from org.hibernate.auction.AuctionItem a inner join a.bids b [java] SQL: [java] select [java] auctionite0_.description as col_0_0_, [java] auctionite0_.seller as col_1_0_, [java] auctionite3_.description as col_2_0_, [java] user2_.id as id2_, [java] user2_.userName as userName2_, [java] user2_."password" as password3_2_, [java] user2_.email as email2_, [java] user2_.firstName as firstName2_, [java] user2_."initial" as initial6_2_, [java] user2_.lastName as lastName2_ [java] from [java] AuctionItem auctionite0_ [java] inner join [java] Bid bids1_ [java] on auctionite0_.id=bids1_.item, [java] AuctionItem auctionite3_ [java] inner join [java] AuctionUser user2_ [java] on auctionite0_.seller=user2_.id [java] where [java] bids1_.item=auctionite3_.id Erreur: [java] org.hibernate.exception.SQLGrammarException: could not execute query [java] at org.hibernate.exception.SQLStateConverter.convert(SQLStateCon verter.java:67) [java] at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExcep tionHelper.java:43) [java] at org.hibernate.loader.Loader.doList(Loader.java:2216) [java] at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java: 2104) [java] at org.hibernate.loader.Loader.list(Loader.java:2099) [java] at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:37 8) [java] at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslato rImpl.java:338) [java] at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryP lan.java:172) [java] at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121) [java] at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79) [java] at org.hibernate.auction.Main.testOracleJoins(Main.java:359)

    Hibernate JIRA | 8 years ago | Philippe Chaléat
    org.hibernate.exception.SQLGrammarException: could not execute query
  3. 0

    Full text search exception with special characters in PostgreSQL

    Stack Overflow | 4 years ago | christopher wilbert
    org.hibernate.exception.SQLGrammarException: could not execute query
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    selecting list of object using HQL when the object is a property of another entity class

    Stack Overflow | 2 years ago
    org.hibernate.exception.SQLGrammarException: could not execute query
  6. 0

    Using a NamedQuery with a composite class

    Stack Overflow | 8 years ago | Ascalonian
    org.hibernate.exception.SQLGrammarException: could not execute query

    3 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.hibernate.exception.SQLGrammarException

      could not execute query

      at org.hibernate.exception.SQLStateConverter.convert()
    2. Hibernate
      QueryLoader.list
      1. org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
      2. org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
      3. org.hibernate.loader.Loader.doList(Loader.java:2216)
      4. org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
      5. org.hibernate.loader.Loader.list(Loader.java:2099)
      6. org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
      6 frames
    3. Hibernate HQL/JP-QL Parser
      QueryTranslatorImpl.list
      1. org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
      1 frame
    4. Hibernate
      QueryImpl.list
      1. org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
      2. org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
      3. org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
      3 frames
    5. org.hibernate.auction
      Main.testOracleJoins
      1. org.hibernate.auction.Main.testOracleJoins(Main.java:359)
      1 frame