-->
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.  [ 3 posts ] 
Author Message
 Post subject: HQL error : could not execute query
PostPosted: Wed Jul 22, 2009 6:13 am 
Newbie

Joined: Wed Jul 15, 2009 1:47 pm
Posts: 4
Hi,

Can you tell me why this HQL is wrong :

Code:
<query name="FluxDao.getLast">
      select f from Flux f where f.id = (select max(f.id) from f where f.courrier.nodeRefId=:courrier_nid)
     </query>


And the calling method :

Code:
HibernateCallback getLastCallback = new HibernateCallback() {

         public Object doInHibernate(Session session) {

            Query query = session.getNamedQuery( "FluxDao.getLast" );
            query.setString( "courrier_nid", pNodeRefId );
            return query.uniqueResult();
         }
      };
      Flux lFlux = (Flux) ht.execute( getLastCallback );


Help me please for the syntax error.


Top
 Profile  
 
 Post subject: Re: HQL error : could not execute query
PostPosted: Wed Jul 22, 2009 7:17 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
You're using the same alias in the query and the subquery. Try to use f1,f2 or f, ff ...

_________________
--Wolfgang


Top
 Profile  
 
 Post subject: Re: HQL error : could not execute query
PostPosted: Thu Jul 23, 2009 5:55 am 
Newbie

Joined: Wed Jul 15, 2009 1:47 pm
Posts: 4
Absolutely right !

Thank you very much :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.