On Wed, Aug 03, 2005 at 10:40:46AM +0100, James, Steven wrote:
> did you try it and what were the errors..
for now I'm trying to play with this query.
<statement id="dynamicGetRule"
resultClass="com.greenvalley.TMS.MML.Entity.Rule">
select distinct r.rule_id,r.name,r.description from rule r left join
rule_field rf
on r.rule_id = rf.rule_id
<dynamic prepend=" WHERE ">
<isNotNull prepend=" AND " property="name"> r.name like #name# </isNotNull>
<isNotNull prepend=" OR " property="description"> r.description like
#description# </isNotNull>
<isNotNull property="fields" >
<iterate prepend="AND" property="fields"
open="(" close=")" conjunction="OR">
<isNotNull property="field">
rf.name like #field#
</isNotNull>
<isNotNull prepend=" AND " property="value">
rf.value like #value#
</isNotNull>
</iterate>
</isNotNull>
</dynamic>
order by name limit #offset#,#limit#</statement>
The strange thing - I provided the methods getField and getValue for
non-existent properties, which are returning the current elements of the
collection (there is internal counter for the fields and values).
This query with fields('%from%') and values(empty) does not returns anything
but with the small modification:
<iterate prepend="AND" property="fields"
open="(" close=")" conjunction="OR">
rf.name like #fields[]#
<isNotNull prepend=" AND " property="value">
rf.value like #value#
</isNotNull>
it works pretty fine.
I added the debug statements to the methods getField and getValue, and found
this:
Getting field %from%
Getting value null
Getting field null
any ideas why it calls the getField() 2 times while there is 1 element in the
collection?
And why the query does not work in first case?
--
Eugene N Dzhurinsky