ibatis-user-cs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrea Tassinari <andre...@i-mconsulting.com>
Subject nullValue in ResultMap simply does not work
Date Fri, 28 Sep 2007 10:05:46 GMT
Hello,

I'm wondering why nullValue attribute does not work at all to me. Consider the following snippets

<!-- sqlMap -->
<resultMaps>
   <resultMap id="IssueResultMap" class="Issue">
      <result property="Id" 
               column="Id" 
               type="Guid" 
               dbType="UniqueIdentifier" />
       <result property="IssueDate" 
               column="IssueDate" 
               type="DateTime" 
               dbType="DateTime" 
               nullValue="1/1/0001 12:00:00 AM" />
   </resultMap >
</resultMaps>

<!-- this does **not** work, sqlclient complains about IssueDate-->
<insert id="Insert" parameterClass="Issue">
   INSERT 
     INTO ISSUES 
          (Id, IssueDate)
     VALUES
          (#Id#,#IssueDate#)
</insert>

<!-- this **does** work -->
<insert id="InsertIssue" parameterClass="Issue">
   INSERT 
     INTO ISSUES 
          (Id, IssueDate)
     VALUES
          (#Id#,#IssueDate:DateTime:1/1/0001 12:00:00 AM#)
</insert>

//CS snippet
Issue issue = new Issue();

//this is only for clarity sake, actually performed by the contructors.
issue.IssueDate = new DateTime(); 

//finally persist to DB
_mapper.Insert("InsertIssue", issue);

Is there a reason for that? I am wrong or else? It *is* very boring and error-prone to write
all nullValue condition in the inline form (consider that I have over 200 insert/update statements
in my app.

My system:

.NET 2.0
iBatis DataMapper 1.6.1 GA binary version
Sql Server 2.0
using provider sqlServer2.0 as shipped in providers.config

Thanks for any support.

--
Kind Regards
Andrea


Mime
View raw message