Unfortunately the database was inherited along with the rules.  In code I
want to work with null strings, so I want iBatis to do the translation for
me (keep the database happy by converting null to empty string on the way
in, and convert empty string to null on the way out out of the database to
keep code consistent).  The one table with different rules is shared with
another system where nullable varchars are allowed.  This is one of my
favorite features of iBatis that you can do these type of translations
without having to change how my code handles things.

Thanks for the suggestion.

On 8/2/07, Clough, Samuel (USPC.PRG.Atlanta) <[EMAIL PROTECTED]>
wrote:
>
> I would expect you'd have to create a custom type handler, but I'm not
> sure.  My question would be if your strings should never be null,
> shouldn't this be implemented in the domain model and not the iBatis
> layer?  For example, every private field could be initialized to be
> equal to string.Empty and on your set properties it should set the field
> to empty if it's null, i.e.:
>
> set
> {
>         privateField_ = value == null ? string.empty : value;
> }
>
> That combined with making the column not null should prevent any null
> string... Just my .02...
>
> -----Original Message-----
> From: Michael Schall [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, August 01, 2007 6:03 PM
> To: [email protected]
> Subject: Using standard TypeHandlers after specifying Custom one.
>
> I have a system with hundreds of tables that I would like to use a
> custom string handler.  It will insert empty string instead of null
> for both varchar and text dbTypes.  I specify it in the SqlMap.config
> file and it works great.
>
> <typeHandler
>         type="string"
>         dbType="varchar"
>         callback="Foo.EmtpyStringToNull, Foo"/>
> <typeHandler
>         type="string"
>         dbType="text"
>         callback="Foo.EmtpyStringToNull, Foo"/>
>
> Now on one table I need to revert back to the way the normal usage
> (Null string inserts Null).  How can I do this?  Do I need to create a
> custom handler to revert back or can I somehow tell iBatis to use the
> standard handler in the parameter map?  I need this for a procedure,
> so inline will not work.
>
> Thanks
> Mike
> --------------------------------------------------------
>
> Princeton Retirement Group, Inc - Important Terms
> This E-mail is not intended for distribution to, or use by, any person or
> entity in any location where such distribution or use would be contrary to
> law or regulation, or which would subject Princeton Retirement Group, Inc.
> or any affiliate to any registration requirement within such location.
> This E-mail may contain privileged or confidential information or may
> otherwise be protected by work product immunity or other legal rules. No
> confidentiality or privilege is waived or lost by any mistransmission.
> Access, copying or re-use of information by non-intended or non-authorized
> recipients is prohibited. If you are not an intended recipient of this
> E-mail, please notify the sender, delete it and do not read, act upon,
> print, disclose, copy, retain or redistribute any portion of this E-mail.
> The transmission and content of this E-mail cannot be guaranteed to be
> secure or error-free. Therefore, we cannot represent that the information in
> this E-mail is complete, accurate, uncorrupted, timely or free of viruses,
> and Princeton Retirement Group, Inc. cannot accept any liability for E-mails
> that have been altered in the course of delivery. Princeton Retirement
> Group, Inc. reserves the right to monitor, review and retain all electronic
> communications, including E-mail, traveling through its networks and systems
> (subject to and in accordance with local laws). If any of your details are
> incorrect or if you no longer wish to receive mailings such as this by
> E-mail please contact the sender by reply E-mail.
>
> --------------------------------------------------------
>

Reply via email to