-->
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: NamedQuery with multiple Parameters
PostPosted: Mon Sep 10, 2012 9:48 am 
Newbie

Joined: Mon Sep 10, 2012 9:38 am
Posts: 2
Hello,

This is perhaps a bit of a newbie question, but I haven't been able to find an example of a NamedQuery with multiple parameters. This is the one I have:

@NamedQuery(name="mynamedquery", query="SELECT user FROM User user WHERE user.foo=:foo AND user.bar:=bar")

which is called later:

Query query = em.createNamedQuery("mynamedquery").setParameter("foo", user.foo).setParameter("bar", user.bar);

and the exception: "Errors in named queries"


I'd like to find a working example so I can find the mistake?? All the examples I have found only have one parameter (and this works if I delete the AND user.bar:=bar)

Thank you!


Top
 Profile  
 
 Post subject: Re: NamedQuery with multiple Parameters
PostPosted: Mon Sep 10, 2012 10:26 am 
Beginner
Beginner

Joined: Wed Jul 20, 2011 5:07 am
Posts: 23
you have got error user.bar=:bar

Be careful because you can not used spaces when you add parameter so this is wrong user.bar = : user


Top
 Profile  
 
 Post subject: Re: NamedQuery with multiple Parameters
PostPosted: Mon Sep 10, 2012 10:50 am 
Newbie

Joined: Mon Sep 10, 2012 9:38 am
Posts: 2
oh totally a newbie error! Thanks for helping me see that!


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.