We've been using the stable version of Ibatis for a while and recently
upgraded to the latest alpha version 1.1.0.458. The old version was
able to handle mapping the .Net bool type to SqlServer's Bit column.
When we run sql maps that contain a bool property, we now get an
exception:

 Exception: System.Data.SqlClient.SqlException
 Message: Syntax error converting the nvarchar value 'False' to a
column 
 of data type bit.
 Source: .Net SqlClient Data Provider

The problem is easily solved by telling Ibatis what the db type should
be. The working code in the old version:

 HasText = #HasText#

needs to be changed to:

 HasText = #HasText:Bit#

That's not a difficult thing to change but I'm curious as to why it
stopped worked? I like keeping my sql maps as generic as possible. It
seems like with every new release of Ibatis the number of auto mappings
between .Net types and DB column types gets smaller and smaller. One of
the things I like about Ibatis is that simple sql statements translate
into simple sql maps:

 Name = #Name#,
 HasExternalLink = #HasExternalLink#,
 HasFile = #HasFile#,
 HasText = #HasText#,                           
 DateLastUpdated = #DateLastUpdated#

If I have to start worrying about specific database types like
:VarChar, :String, :Bit, :Date, :DateTime, etc. things get more verbose
and porting between databases becomes more difficult:

 Name = #Name:String#,
 HasExternalLink = #HasExternalLink:Bit#,
 HasFile = #HasFile:Bit#,
 HasText = #HasText:Bit#,                               
 DateLastUpdated = #DateLastUpdated:DateTime#

Am I doing something wrong in the build I'm using that would prevent
Ibatis from automatically mapping bool to Bit?

- Ron

Reply via email to