* 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: Could 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.