jQuery in Action, 3rd edition
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
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Named queries and EJBQL " Watch "Named queries and EJBQL " New topic

Named queries and EJBQL

Sharon Adar

Joined: Apr 29, 2007
Posts: 18

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?

Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32649

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.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Sharon Adar

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!
I agree. Here's the link: http://aspose.com/file-tools
subject: Named queries and EJBQL
It's not a secret anymore!