## Friday, June 9, 2006

### iBATIS parameterClass and resultClass attributes - Don't mix them up!

I just spent an hour chasing down one of the dumbest bugs ever. As anybody who works with iBATIS knows, a simple select mapped statement without any parameters looks similar to this:

<select id="mySelect" parameterClass="MyClass">
select * from my_table where some_criteria = #someValue#
</select>


I was scratching my head for the longest time trying to figure out why no results were returned, even though there were some 900 rows in the database.

Taking a closer look at that mapped statement: I specified the parameterClass attribute instead of resultClass attribute. So if the statement returns results and iBATIS doesn't know how to map those results to a class, it will just return an empty List. How helpful.

The lesson? Don't be stupid like me, and don't mix up your parameterClass and resultClass attributes.

# Update

And also note that it should be #someValue# if you want to access a bean property, and 'someValue' if you actually want to search for the literal someValue!