-->
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: "not exists" in the hibernate named query
PostPosted: Mon Mar 16, 2009 11:45 am 
Newbie

Joined: Fri Jan 09, 2009 11:05 am
Posts: 3
I use hibernate version 3.2.5.ga.
I am trying to use "not exists" in the named query like that:

<query name="GetNetworkUsersExceptTheseIds" cacheable="false">
<![CDATA[select u
from User as u
inner join u.userNetworks as un
inner join un.network as n
where n.id in (:nw_id)
and not exists(
select u1
from User u1
inner join userRoles as ur
inner join ur.role as rt
where u.id = u1.id
and rt.sort_order >= :role_sort_order)
order by u.lastName asc]]>
</query>

It gives me a parsing error ane tells me:
org.hibernate.hql.ast.QuerySyntaxException: Path expected for join!

I would appreciate if somebody hellps me to understand what's the problem.

Thank you
Natalie


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 16, 2009 12:15 pm 
Regular
Regular

Joined: Mon Jan 05, 2009 6:42 pm
Posts: 99
Location: IL
Hi Natalie,
what is the database you are trying to use?
Can you post your DAO code? I think there is a minor possible syntax error in the HQL projection..

I would first test the DAO with this query:-
<query name="GetNetworkUsersExceptTheseIds" cacheable="false">
<![CDATA[
from User as u
inner join u.userNetworks as un
inner join un.network as n
where n.id in (:nw_id)
order by u.lastName asc]]>
</query>

and see if this works.And then extend as:-
<query name="GetNetworkUsersExceptTheseIds" cacheable="false">
<![CDATA[
from User as u
inner join u.userNetworks as un
inner join un.network as n
where n.id in (:nw_id)
and u.id not in(
select u1.id
from User u1
inner join userRoles as ur
inner join ur.role as rt
where u.id = u1.id
and rt.sort_order >= :role_sort_order)
order by u.lastName asc]]>
</query>

In both the cases you will get List<User> instances.

Hope this helps,
Latha.


Top
 Profile  
 
 Post subject: "not exists" in the hibernate named query
PostPosted: Mon Mar 16, 2009 2:52 pm 
Newbie

Joined: Fri Jan 09, 2009 11:05 am
Posts: 3
Hi Latha,

Thank you very much for suggestions.

I did "not in" and did identify some syntax errors.
After "not in" run correctly I switch to "not exists".

Everything works fine now.

Thanks again, Natalie


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.