byte? doesn't work as a type in parameterMap

286 views
Skip to first unread message

Paul

unread,
Dec 31, 2010, 10:33:01 AM12/31/10
to mybatis...@googlegroups.com
According to your docs, using "byte?" as a type value should work in parameterMap.  I'm using DataMapper version 1.6.1.

The error message I'm getting is: Could not load type from string value 'byte?'.

It's a configuration exception which shows this information in the stack trace:

The error occurred while loading SqlMap.
- Check the parameter mapping typeHandler attribute '' (must be a ITypeHandlerCallback implementation).
- The error occurred in <sqlMap embedded="OwnerRez.Application.Data.Config.Rate.xml, OwnerRez.Application" xmlns="http://ibatis.apache.org/dataMapper" />.
- Check the Rate.InsertParams.]

Here's the XML block for Rate.InsertParams:

  <parameterMaps>
    <parameterMap id="InsertParams" class="Rate">
      <parameter property="RateId" column="RateId" type="int"/>
      <parameter property="Name" column="Name" type="string" size="32"/>
      <parameter property="ExtraChargeTypeId" column="ExtraChargeTypeId" type="byte?"/>
      <parameter property="ExtraCharge" column="ExtraCharge" type="decimal?"/>
    </parameterMap>
  </parameterMaps>

Michael Schall

unread,
Jan 12, 2011, 10:46:33 AM1/12/11
to mybatis...@googlegroups.com
I have not tried this with bytes, but with integers...

You have a few options:
1) just use type="byte"
2) don't specify the type
3) byte? is syntactic sugar for .net type name System.Nullable`1[[System.Byte]]

We usually try to specify the type attribute, but both 1 and 2 work fine for us...  You could try 3.

Mike

Andrea Tassinari

unread,
Jan 12, 2011, 12:01:47 PM1/12/11
to mybatis...@googlegroups.com

MyBatis Version 1.6.2 GA

I use option 1) (with both .Net 2.0 and 4.0) and it works. DateTime and
Guid types behaves the very same way. I have planty of DateTime?
property simply mapped as DateTime and nullable property type is
correctly handled by MyBatis. Moreover

public class Job
{
private DateTime? _lastExecutionDate;

//..........

public DateTime? LastExecutionDate {
get { return lastExecutionDate; }
set { lastExecutionDate = value; }
}
}

//WORKING MAPPING (nullable handled correctly)
<result property="LastExecutionDate" column="LastExecutionEndDate"
type="DateTime" dbType="DateTime" />

//NOT WORKING MAPPING (please note the question mark in attribute type):
MyBatis fails to configure itself
<result property="LastExecutionDate" column="LastExecutionEndDate"
type="DateTime?" dbType="DateTime" />


Andrea

Reply all
Reply to author
Forward
Message has been deleted
0 new messages