This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes Named queries and EJBQL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Named queries and EJBQL " Watch "Named queries and EJBQL " New topic
Author

Named queries and EJBQL

Sharon Adar
Greenhorn

Joined: Apr 29, 2007
Posts: 18
Hey,

I�m trying to write a named query which uses an �in� query �
something like : select * from Drink d where name in (�coke�,�7up�,�)
I can�t use parameters, since I don�t know how many of them are.
Neither can I pass a string like �coke,7up,�� .

Any idea?

Thanks!
Sharon.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30123
    
150

Sharon,
You can't use a named query for this. Your choices are to do the query one drink name at a time or to use a native SQL query.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Sharon Adar
Greenhorn

Joined: Apr 29, 2007
Posts: 18
Surprisingly I can!

You can pass multiple parameters as a list.

For example:

The named query :


Using the named query (and setting the parameter!):


It works!
Annoying.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Named queries and EJBQL
 
Similar Threads
JTable refreshment -- or was that 7up?
The giberish thread
Coke or Pepsi
Will you drink Coca Cola
AOL moves to India