• Post Reply Bookmark Topic Watch Topic
  • New Topic

EJB - QL finder methods  RSS feed

 
Sany Bel
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I use EJB-QL if I have a finder method that takes a list of ids as parameter. For eg., if I have to get the objects whose ids are in the list of ids passed to the finder method, how can I do it through EJB-QL?
[ April 29, 2004: Message edited by: Chris Mathews ]
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you looked at the EJB-QL portion of the EJB specification? You should probably do that.
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EJBQL only works on a static number of parameters so you can't really do what you want in a standard way without restorting to Java code. However, many vendor offer extensions to allow dynamic query creation in CMP for just these types of problems, check your Application Server's documentation.
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In case you got around to looking at the EJB-QL BNF, you should notice that it doesn't allow you to do something like "SELECT OBJECT(o) FROM Something AS o WHERE o.value IN ?1" where ?1 is defined as a Collection (or other container type).
A home method may be what you need to accomplish this.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!