-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Hibernate query problem
PostPosted: Wed Dec 05, 2007 7:02 pm 
Newbie

Joined: Fri Oct 20, 2006 12:55 pm
Posts: 12
Hey everyone,

I've been using Hibernate for quite some time, but recently I've been having trouble with a particular query :
query = "from com.mypackage.ProcessedCheque c " +
"where c.originalRequest.id in (:ids) " +
"order by c.originalRequest.id asc"

I've got numerous other queries that are virtually identical, but this one always throws an IllegalArgumentException saying : "node to traverse cannot be null". I can't see anything wrong with the syntax. Can somebody please help me out and lend a fresh pair of eyes ?


Hibernate version: 3.2.5GA

Mapping documents: None, annotations

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:
java.lang.IllegalArgumentException: node to traverse cannot be null!
at org.hibernate.hql.ast.util.NodeTraverser.traverseDepthFirst(NodeTraverser.java:31)
at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:254)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:157)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
at org.hibernate.engine.query.HQLQueryPlan.<init>(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 org.springframework.orm.hibernate3.HibernateTemplate$30.doInHibernate(HibernateTemplate.java:868)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:372)
at org.springframework.orm.hibernate3.HibernateTemplate.findByNamedParam(HibernateTemplate.java:866)
at org.springframework.orm.hibernate3.HibernateTemplate.findByNamedParam(HibernateTemplate.java:857)
at com.mypackage.businesslogic.services.impl.hibernate.HibernateProcessedChequeServiceImpl.getByOriginalRequestIdSorted(HibernateProcessedChequeServiceImpl.java:112)
at com.mypackage.api.xml.requestHandlers.ExternalProcessorRequestHandler.handleUpdateRequest(ExternalProcessorRequestHandler.java:123)
at com.mypackage.api.xml.requestHandlers.ExternalProcessorRequestHandler.handleRequest(ExternalProcessorRequestHandler.java:76)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:296)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:177)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy78.handleRequest(Unknown Source)
at com.mypackage.api.xml.impl.XmlGatewayImpl.handleRequest(XmlGatewayImpl.java:87)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:296)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:177)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:77)
at com.mypackage.buslogic.aspects.LoggingAdvice.adviseXmlGatewayLogging(LoggingAdvice.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:576)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:562)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:60)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:155)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy79.handleRequest(Unknown Source)
at com.mypackage.api.pox.PoxGateway.handleRequest(PoxGateway.java:69)
at com.mypackage.api.pox.PoxGatewayTest.testChequeUpdate(PoxGatewayTest.java:909)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:69)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

Name and version of the database you are using: MySQL 5.0.24

The generated SQL (show_sql=true): None

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 02, 2008 12:50 am 
Newbie

Joined: Sun Nov 11, 2007 7:53 am
Posts: 2
query doesn't have select clause.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 02, 2008 3:35 am 
Newbie

Joined: Fri Oct 20, 2006 12:55 pm
Posts: 12
The query is in HQL though, it doesn't require a select clause.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 02, 2008 10:56 am 
Newbie

Joined: Tue Jan 22, 2008 9:53 am
Posts: 18
YOu're right.
your HQL doesn't need the select.
The problem is probably in this part of the query:
"where c.originalRequest.id in (:ids) "

ids is a field from what table ? how is you database schema and mapping ?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 02, 2008 5:07 pm 
Newbie

Joined: Fri Oct 20, 2006 12:55 pm
Posts: 12
The 'originalRequest' field / property is of type PaymentRequest and it has a field / property called 'id'. ProcessedCheque and PaymentRequest have a ManyToOne mapping (ie there can be many ProcessedCheques for a given PaymentRequest). I'm using Hibernate / EJB3 annotations within a spring application that creates the SessionFactory using a Spring AnnotationSessionFactoryBean. The mapping for 'originalRequest' is :
Code:
   @ManyToOne(fetch = FetchType.EAGER, cascade = {CascadeType.ALL})
   @JoinColumn(name = "payment_request_id", nullable = false)
   @NotNull(message = "{error.field.not_set}") @Valid
   private PaymentRequest   originalRequest;


...and as you can see, I'm using Hibernate Validator for my validation, both at the presentation and persistence layers.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.