14455

java.lang.ClassCastException: org.hibernate.hql.ast.tree.SqlNode cannot be cast to org.hibernate.hql

Question:

Im trying to update a record with a <em>HQL</em> query but I am getting a CastException. If anyone could help me out I would really appreciate it. I have checked the Internet for a while now but I cant find any information on this. Please let me know if you have more information on this exception.

The full error message its returning:

Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: org.hibernate.hql.ast.tree.SqlNode cannot be cast to org.hibernate.hql.ast.tree.FromReferenceNode at org.hibernate.hql.ast.HqlSqlWalker.generateSyntheticDotNodeForNonQualifiedPropertyRef(HqlSqlWalker.java:495) at org.hibernate.hql.ast.HqlSqlWalker.lookupNonQualifiedProperty(HqlSqlWalker.java:488) at org.hibernate.hql.antlr.HqlSqlBaseWalker.propertyRef(HqlSqlBaseWalker.java:1102) at org.hibernate.hql.antlr.HqlSqlBaseWalker.assignment(HqlSqlBaseWalker.java:1008) at org.hibernate.hql.antlr.HqlSqlBaseWalker.setClause(HqlSqlBaseWalker.java:729) at org.hibernate.hql.antlr.HqlSqlBaseWalker.updateStatement(HqlSqlBaseWalker.java:349) at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:237) at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:228) at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:160) at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111) at org.hibernate.engine.query.HQLQueryPlan.(HQLQueryPlan.java:77) at org.hibernate.engine.query.HQLQueryPlan.(HQLQueryPlan.java:56) at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72) at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133) at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112) at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623) at Database.HibernateConnection.updateFlight(HibernateConnection.java:161) at Controller.Controller.ChangeFlight(Controller.java:527) at View.CreateChangeFlightView.btnSaveActionPerformed(CreateChangeFlightView.java:738) at View.CreateChangeFlightView.access$1000(CreateChangeFlightView.java:45) at View.CreateChangeFlightView$6.actionPerformed(CreateChangeFlightView.java:299) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236) at java.awt.Component.processMouseEvent(Component.java:6263) at javax.swing.JComponent.processMouseEvent(JComponent.java:3267) at java.awt.Component.processEvent(Component.java:6028) at java.awt.Container.processEvent(Container.java:2041) at java.awt.Component.dispatchEventImpl(Component.java:4630) at java.awt.Container.dispatchEventImpl(Container.java:2099) at java.awt.Component.dispatchEvent(Component.java:4460) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168) at java.awt.Container.dispatchEventImpl(Container.java:2085) at java.awt.Window.dispatchEventImpl(Window.java:2478) at java.awt.Component.dispatchEvent(Component.java:4460) at java.awt.EventQueue.dispatchEvent(EventQueue.java:599) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

query: deleted

Answer1:

The problem is caused by the fact that from is a reserved word in HQL. Since it's not possbile to escape a keyword in HQL, the only possbile solution is to rename that field.

Recommend

  • JPA query in multiple tables with many-to-many relationship
  • How to get ANTLR 3.2 to exit upon first error?
  • Recursive logic for parsing string into complex boolean?
  • Could not find method include() for arguments [:app] on root project 'myProject'
  • Class not mapped exception (but it is mapped)?
  • java.lang.ClassNotFoundException: antlr.ANTLRException but I have antlr-2.7.6 in folder lib of proje
  • What is the wrong with the simple ANTLR grammar?
  • Permutations list repeating itself when returning ArrayList in toString method
  • Error : “Transport endpoint is already connected”
  • Numpy doesn't change value of an array element after masking
  • Assign Returned Pointer to Array
  • Basic Objective-C syntax commonly used in init methods [duplicate]
  • No setter method for assignment to property swift 3 with objective-c
  • Return a Disposable object for use in a using block
  • Typecasting with shorthand operators
  • Java Linked List How to create a node that holds a string and an int?
  • Memory Barriers: a Hardware View for Software Hackers Example 3
  • Azure Table Partitioning Strategy
  • How to hide a vanilla button according to form state
  • Why does a type conversion not work in Java [duplicate]
  • casting issue with realpath function (c programming)
  • Return the line number of the last character for current token
  • Global assignment within a reactive expression in R Shiny?
  • How to print preprocessor macros under Sun Studio?
  • Changing what THIS is
  • How to use Boost Spirit with variant with more than 20 types?
  • Memory allocation for incremental garbage collection simulation in c++
  • Python Power Set of a List [duplicate]
  • Shell script: How to prevent SIGINT from interrupting current task
  • Python: How to make a function that asks for the exact amount of words?
  • Intrinsic Assignment and Polymorphism in Fortran 2003
  • Python how to create a dict of dict of list with defaultdict
  • why we have clear function when we can assign string to “” in cpp
  • MATLAB Combine matrices of different dimensions, filling values of corresponding indices
  • Interrupting boost thread
  • initializing array of variable size inside a class
  • Mocking a imported function with pytest [duplicate]
  • Best practice to eliminate magic numbers within a member function
  • Meteor: Do Something On Email Verification Confirmation
  • Function pointer “assignment from incompatible pointer type” only when using vararg ellipsis