[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - How to write a finder query that takes a collection paramete

jwiegley do-not-reply at jboss.com
Fri Mar 2 16:37:34 EST 2007


I have an older BES codebase which I'm trying to port to JBoss.  Since that codebase targets EJB CMP 1.x -- and has no concept of local interfaces, etc. -- the best approach so far seems to be to get JBoss to deploy those 1.x beans as they are.

However, BES allows for finder queries like this:

<finder>
  |   <method-signature>findByResourceList( String[] asResourceIDList )</method-signature>
  |   <where-clause> MyResourceID in ( :asResourceIDList ) </where-clause>
  | </finder>

I thought that in my jbosscmp-jdbc.xml file, I could just write this to emulate the above:

<query>
  |   <query-method>
  |     <method-name>findByResourceList</method-name>
  | 	<method-params>
  | 	    <method-param>java.lang.String[]</method-param>
  | 	</method-params>
  |     </query-method>
  |     <declared-sql>
  | 	<where>ID in ({0})</where>
  |     </declared-sql>
  | </query>

However, while this builds, deploys and executes without a hitch, it does not find anything.  I'm not sure what substitution syntax {0} results in in this case.

Anyway, can anyone offer a clue as to how to pass a collection as a finder parameter, and then query my database to check for any entries whose ID matches any member of that collection?

Thanks,
  John

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

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



More information about the jboss-user mailing list