[ http://issues.apache.org/jira/browse/IBATISNET-159?page=comments#action_12412412 ]
Jeremy Gray commented on IBATISNET-159: --------------------------------------- I'd be happier of one of the official maintainers were able to comment on this issue, but as best as I can tell, the prepend value of "and" will only be output if _another_ is* element is satisfied _before_ the one where your prepend="and" is specified. This is so that you don't end up with a query that reads "... where and ...". The CDATA section you have baked into the top of your dynamic element is throwing you off a bit, as that portion isn't conditional and shouldn't be in the dynamic section. Moving it out would also require the removal of the prepend="WHERE" from the dynamic element. At that point you should be able to clearly see why your prepend="and" would never fire. > prepends are not working in some cases > -------------------------------------- > > Key: IBATISNET-159 > URL: http://issues.apache.org/jira/browse/IBATISNET-159 > Project: iBatis for .NET > Type: Bug > Components: DataMapper > Versions: DataMapper 1.3 > Environment: Win2000 Server, WinXP .Net Framework 2.0 > Reporter: Michael Schall > > I have posted a question to the newsgroup. > http://www.mail-archive.com/[email protected]/msg00874.html > In certain cases the prepend is not working correctly. > I get a "sql error > near tp_Calls". The prepends aren't adding in the "and" to the > resultant sql string. > <dynamic prepend="WHERE"> > <![CDATA[ > OffHookDt <= #EndDate# AND > OffHookDt >= #StartDate# > ]]> > <isNotNull property="LocationCode"> > <isNotEqual prepend="and" property="LocationCode" > compareValue="%"> > tp_Calls.LocationCd = #LocationCode# > </isNotEqual> > </isNotNull> > <isNotEqual prepend="and" property="RateType" compareValue="-1"> > RateType = #RateType# > </isNotEqual> > <isEqual prepend="and" property="PrivateAllowed" compareValue="0"> > tp_Calls.Hidden = 0 > </isEqual> > </dynamic> > If I change it to the following everything works great. > <dynamic prepend="WHERE"> > <![CDATA[ > OffHookDt <= #EndDate# AND > OffHookDt >= #StartDate# > ]]> > <isNotNull property="LocationCode"> > <isNotEqual property="LocationCode" compareValue="%"> > and tp_Calls.LocationCd = #LocationCode# > </isNotEqual> > </isNotNull> > <isNotEqual property="RateType" compareValue="-1"> > and RateType = #RateType# > </isNotEqual> > <isEqual property="PrivateAllowed" compareValue="0"> > and tp_Calls.Hidden = 0 > </isEqual> > </dynamic> -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
