-->
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.  [ 1 post ] 
Author Message
 Post subject: Sub query in @NamedQuery ? (with order by and rownum)
PostPosted: Wed Nov 26, 2008 3:44 am 
Newbie

Joined: Wed Nov 26, 2008 3:26 am
Posts: 2
I have a query which join many tables and retrives a sorted list of objects.
If my parent table has two children records, i am getting a list of 3 records as result. So i have used rownum to get only one(first) record.

My query looks like this:

@NamedQuery(name = "getResultByStatus", query = "select new com.Result(id, updatedDateH) from (select a.id as id, b.updatedDate as updatedDateH from User u,Parent a left outer join a.child b where a.status = :status and (u.id=b.updatorId or u.id=a.creatorId) order by b.updatedDate desc) where rownum<2")

this gives me the error:
QuerySyntaxException: unexpected token: select near line 1.

Would you please help me on this ?


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

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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.