After much effort I have come to the conclusion that using the in clause in an 
ejb-ql will only work in cases where you know exactly how many elements will be 
in the in clause.  This does not work in my case since I need my in clause to 
be dynamic.

The in clause is defined like this.


  | in_expression ::=
  |     cmp_path_expression [NOT ] IN
  |     ( {literal | input_parameter} 
  |     [, { literal | input_parameter} ]*) 
  | 

If I understand the above BNF correctly you have to either pass in a literal or 
a variable for each element of the IN list.  In my case I needed to have a 
dynamic number of elements in my IN clause.  I don't want to use a hard coded 
IN clause with a set number of elements.

My solution was to do the following.  I had a list of primary keys for the 
table I was interested in.

I created a loop that iterated through each primary key.  Then for each primary 
key I did the following.


  |             for (int i = 0; i < sRows.length; ++i) {
  |                 pricMatrixEntity = 
pricMatrixEntityHome.findByPrimaryKey((String) sRows);
  |                 if (pricMatrixEntity != null) {
  |                     adjustEntity(pricMatrixEntity, bInc, fPercent, aCols);
  |                 }
  |             }
  | 

I think it ridiculous that the ejb-ql code can't handle a dynamic IN clause.  
Maybe I misunderstand the code but my solution worked.  Anybody have any 
experience with this?

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3881290#3881290

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3881290


-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.  How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy.  
Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to