• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Named queries and EJBQL

 
Sharon Adar
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34656
366
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sharon Adar
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic