ibatis-user-cs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ron Grabowski <rongrabow...@yahoo.com>
Subject Re: Custom DateTime type handler that overrides IBatisNet's DateTimeTypeHandler
Date Tue, 04 Oct 2005 18:09:31 GMT
I think the "01/01/0001 00:00:00" is ugly. Who has the value of
double.MinValue memorized? 

I don't use parameterMaps. I use the standard #Property# syntax:

 <update id="Update" parameterClass="User">
  UPDATE [User] SET
   [Login] = #Login#,
   [Password] = #Password#,
   [Name] = #Name#,
   [EmailAddress] = #EmailAddress#,
   [DateLastUpdated ]= ${NOW}
  WHERE
   [UserId] = #UserId#
 </update>

In my current project, if I were to switch over to using parameterMaps
I would have to make 15 parameterMap nodes with at least 130 parameter
nodes. That's a lot of typing! If I were working on a larger project
those numbers could be much higer. I don't want to have go through all
of my resultMaps and make sure I changed all the DateTime properties
correctly.

There's nothing special about the default type handlers that ship with
IBatisNet other than the fact that they're the default handlers. Some
people may not like the default implementation or the default
implementation may not work with their project or database.

Some other good reasons to support the ability to globally replace
certain default type handlers:

Replace the default string type handler with one that automatically
converts all strings sent to/from the database to upper case.

Replace the default DateTime type handler with one that automatically
translates a DateTime object into its Ticks representation (i.e. store
DateTime object as long).

Replace the default string type handler with one that automatically
encrypts and decrypts values sent to the database.

Replace the default string type handler with one that automatically
calls Trim() before sending values to the database so values in the
database never have leading or trailing whitespace.

Replace the default double type handler with one that recognizes
double.NaN and automatically stores that as NULL in the database.

Replace the default int type handler with one that recognizes
int.MinValue and automatically stores that as NULL in the database.

Replace the default string handler with one that automatically converts
string.Empty to NULL when sending information to the database.

Replace the default boolean handler with one that automatically
translates true/false into "Y" and "N" in the database.

Replace the default boolean type hanlder that reverses the role of true
and false. When true is encountered it sends false to the database.
When false is encountered it sends true to the database.

Replace the default int type handler with one that translates a
positive number into true, zero to NULL, and a negative number to
false.

Replace the default string type handler with one that removes curse
words before storing data in the database.

Replace the default string type handler with one that strips out
malicious html when storing data in the database (i.e. run a regular
expression on the string before sending it to the database)

Replace the default double type handler with one that converts the
value to an integer before storing it in the database.

Replace the default string type handler with one that reverses the
string before sending it to the database.

Replace the default DateTime type handler that one that ignores the
time fields and only stores the Date part of the object in the
database.

And of course what would a long post be a weird reference to
logginer...replace the default string type handler with one that emits
a log message if a certain value exists in ThreadContext or
HttpContext.

--- Gilles Bayon <ibatis.net@gmail.com> wrote:

> Why don't you use nullValue attribute
> <result property="DateTransmissionPrevue"
> column="DateTransmissionPrevue"
> nullValue="01/01/0001 00:00:00" />
>  <parameter property="DateLimiteTraitement" column="DateLimite"
> nullValue="01/01/0001 00:00:00" />
>  -Gilles
> 


Mime
View raw message