Calling MySQL Procedures from iBatis

I had some issues this morning calling MySQL Procedures from iBatis. The iBatis documentation is pretty sparse on the subject and I could not find anything useful on the forums. I did eventually find the ‘clincher’ post on a mail-archive.com.

Assume this (rather brain-dead) stored procedure:


CREATE PROCEDURE increment_total_widgets (widget_key BINARY(20), increment INT)
BEGIN
UPDATE statistics
SET total_widgets = total_widgets + increment
WHERE widget_key = widget_key;
END;

The procedure setup in the iBatis sqlmap file should be as follows:


<procedure id="incrementTotalWidgets" parameterClass="HashMap">
{CALL increment_total_widgets(UNHEX(#widget_key:VARCHAR#), #increment:NUMBER#)}
</procedure>

This looks nothing like the example set out in the iBatis documentation.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: