This content has been marked as final.
Show 1 reply
-
1. Re: How to write a finder query that takes a collection para
roist Mar 7, 2007 10:55 AM (in response to jwiegley)you may want to check in your server.log (which is quite helpful to me, to understand finding and optimized loading-issues) that the resulting prepared-statement is indeed not what you wanted.
the resulting statement will be ... where ID IN (?), which can't work, since you'd like to have where ID IN(?,?,?) and every parameter filled in. else your db will believe its just one parameter of the ID#type.
a quick and dirty workaround: concatenate the string with some delimiter before passing it to the finder, and write a little database function that explodes your delimiter-seperated list.
best would of cause be to set up cmr properly - but this seems like hard work for a whole application.
oracle-compatible where clause+impl:public xxx findByResourceList (String[] asResourceIDList) { StringBuffer res = new StringBuffer(); res.append(','); for(String s: asResourceIDList) res.append(s).append(','); return findByResourceListDummy(res.toString()); }
<query> <query-method> <method-name> findByResourceListDummy </method-name> <method-params> <method-param>java.lang.String</method-param> </method-params> </query-method> <declared-sql> <where>instr({0}, ',' || id || ',')>0</where> </declared-sql> </query>
though i'm not sure if you can do that function stuff here, it should be possible somewhere;)