You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-cs@ibatis.apache.org by Kit Cragin <ki...@entervalent.com> on 2005/02/01 21:48:56 UTC

Some info on referencing a parameter more than once...

I've found that if you reference a property in a parameterClass or an entry
in a parameterMap more than once, strange behavior results.

For example (where ... = some legal SQL fragment):

<select id="whatever" parameterClass="SomeClass">
  ... #SomeIntProperty# ... #SomeOtherIntProperty# ... #SomeIntProperty# ...
</select>

could produce some sort of SQL error (types of errors I've gotten are
different) or even an error within iBATIS itself before the SQL is sent to
the database. I *think* the reason is that iBATIS is pulling information
from the parameterClass or parameterMap by index after mapping the
parameters to SqlParameters.

The workaround is to do something like this:

<select id="whatever" parameterClass="SomeClass">
  declare @SP int
  select @SP = #SomeIntProperty#
  ... @SP ... #SomeOtherIntProperty# ... @SP ...
</select>

Hope this saves someone some time. Can anyone confirm this issue? If so, I
can enter into Jira.

- Kit