-->
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 on a VIEW
PostPosted: Tue Aug 26, 2008 1:53 pm 
Newbie

Joined: Mon Jul 07, 2008 10:55 am
Posts: 4
hi

i have a VIEW. i am mapping an Nhibernate file to this view.
In the Nhibernate file i am writing HQL to query the VIEW. But i am getting errors like

System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: No positional parameters in query: select memberNote from MemberNotes memberNote where (memberNote.Author = '?') or (memberNote.Author <> '?' and memberNote.Private = 'false').


this is my HQL

return session.CreateQuery("select memberNote from MemberNotes memberNote where (memberNote.Author = '?') or (memberNote.Author <> '?' and memberNote.Private = 'false')").SetString(0, loginUser).SetString(1, loginUser).List<MemberNotes>();


MemberNotes is the Entity class mapping to the View.

i didnt understand why i get the error.
Is it because i have no primary key in the view?
but in the hbm file i have given an id column class as native.
Can anybody help?
Thanks John

_________________
regards
John


Top
 Profile  
 
 Post subject: Remove the single quotes from around the ?
PostPosted: Tue Aug 26, 2008 3:12 pm 
Newbie

Joined: Fri Aug 22, 2008 4:07 pm
Posts: 9
If you remove the single quotes from around the question marks it should work. NHibernate will take care of putting them in for you.

I would recommend that you use the named parameters instead. If you replace your question marks with ":loginUser" (without the double quotes), then you can set the parameters by name instead of position.


Top
 Profile  
 
 Post subject: HQL on a VIEW
PostPosted: Wed Aug 27, 2008 2:19 am 
Newbie

Joined: Mon Jul 07, 2008 10:55 am
Posts: 4
thanks.. that is working

_________________
regards
John


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.