Save Yourself From MyBatis Hell

* This has been sitting in my unpublished posts since February. Time to get it out there! Some of the images look weird, just click to view them.

 

This is the story of how to save yourself from some MyBatis hell.

I had a class called Row:

And a class called ParameterMap:

And a MyBatis map to call a stored procedure to populate an IList of type Row:

The stored procedure was called via a repository, whose test looked like:

When I ran this test, I kept getting this seemingly incorrect error message (“Unable to optimize create instance: Count not find public constructor matching specified argument for type “Row”):

This led me to tons of crazy troubleshooting to see where the following two things differed:

NOW, FOR THE CRUX OF THE MATTER:

The way I solved this and got to the true error was…
By adding a parameterless constructor to my Row class:

Then I ran my repo test again, resulting in the following USEFUL error message:

This led me to examine the sproc, and I noticed that:

DOES NOT EQUAL

Once I changed the casing to “DistrictID,” voila:

THE End.

The moral of the story is: Add a parameterless constructor to the class in question if you get that bogus first error about an incorrect constructor.

DevTalk: The Zeroth Episode

Today I had a blast getting together with fellow blogger and tech colleague, Jeff Vera (aka, the barebonescoder). We decided to start a podcast/videocast series to discuss tech topics and to begin conversations among developers, especially those in the Tampa Bay area.

Though neither of us had done something like this before, we asked ourselves, “How hard could it be?” Answer: Very easy.

It turned out that all we needed was a laptop with a webcam, two bar stools, and a lot of patience with each other as we moved through blooper after blooper onscreen. Eventually we jotted down the initial flow we wanted to follow, and got the time down under ten minutes so we could post it on youtube. Our topic was innocuous enough: blogging.

While this initial podcast was meant to help us “get our feet wet”, we do have a vision for the series, so stay tuned. I’ll be posting information about upcoming topics so you can weigh in before or during the broadcast. If you’d like to be a guest on the series, email me and we’ll skype you in.

Our next topic will be: Women in Software Development.

Permalink: http://thecodergirl.wordpress.com/2011/12/10/devtalk-the-zeroth-episode/ 

Why I Love to Code

I’m a passionate person, pouring my heart and soul into everything I do, including my profession as a software developer. I don’t just sit around and write IF statements and loops all day (like we did in college), or SELECT statements, or lame SVN commit messages (although sometimes those slip out when I’m not looking). I’m not in this for the money, prestige, or political power.

For me, it’s about the thrill of the chase.

I’m a lover of mysteries with a penchant for puzzles and an addiction to problem solving. The fires of this passion were first stoked when, at the age of twelve, I discovered the fictional detective Sherlock Holmes and ravenously devoured the entire series of whodunits in record time. Like a hound fresh on the trail of his quarry, I followed the clues with an electric anticipation, attempting to deduce the solution to the puzzle, the question, the mystery before it was revealed. Unfortunately and alas, this led to a rather unrequited love affair with a fictional character, whose brain I was hopefully smitten with. But at twelve, those things are bound to happen and I got over the fact that we could never be together.

This first affair with mystery set me on an irrevocable path toward problem solving–a path that has been refined through the years by the fine-tuning inherent in studious endeavors. In high school, the passion burst to life again when I began studying chemistry, particularly the periodic table of elements. I remember being fascinated with the fact that the structure and order of the periodic table allowed scientists to deduce the existence and properties of elements that had yet to be actually discovered. Equations and their answers, math and the problems presented, never failed to catapult me into the thrill of the chase in pursuit of their answer.

Since then, leisure time for me has always included some kind of puzzle or game, from crosswords to sudoku to scrabble to boggle to jigsaws to reading stories and watching them unfold. What I find so appealing about a puzzle is not only the pure satisfaction that answering it brings, but also the pleasure experienced in pursuit of that answer. In this sense, the journey is just as important and rewarding as the end. I think Thomas Aquinas put it best when he said that play is valuable because we do it for its own sake, and the result of play is joy. At least, he said something like that. And he’s right.

So what does this have to do with writing code? Everything. Coding is formulating solutions, it is building structures, it is conducting them in a symphony of harmonious accord. Architecture is akin to a tetris puzzle where every piece has its optimal place. Debugging is like following the threads of a mystery, picking up clues until the culprit is apprehended. Production support can be data sleuthing toward an answer. Yes, some parts of development can be tedious, boring, maddening; but then the challenge becomes turning those aspects of it into opportunities for discovery and growth. The passion is in the fun of it.

Permalink:  http://thecodergirl.wordpress.com/2011/12/07/why-i-love-to-code/