You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-cs@ibatis.apache.org by Michael Schall <mi...@gmail.com> on 2007/01/25 19:27:48 UTC
New ITypeHandler NullValue property
Is this the null value "coming from" the database, or "going to" the
database?
>From the code it looks like coming from since it is used in the
ResultProperty class.
For example if I have a nullable varchar field in the database and in an
instance of a class I would like this to be represented by an empty string.
My type handler vb code would look like this:
Public ReadOnly Property NullValue() As Object Implements
IBatisNet.DataMapper.TypeHandlers.ITypeHandlerCallback.NullValue
Get
Return ""
End Get
End Property
If I want null database fields to remain null, the code would look like the
following
Public ReadOnly Property NullValue() As Object Implements
IBatisNet.DataMapper.TypeHandlers.ITypeHandlerCallback.NullValue
Get
Return Nothing
End Get
End Property
Is this correct? There are no docs that I can find about this new
property. I know docs for this release are not completed yet. :)
Thanks for your time.
Mike
Re: New ITypeHandler NullValue property
Posted by Gilles Bayon <ib...@gmail.com>.
On 1/26/07, Michael Schall <mi...@gmail.com> wrote:
>
> I could do it on a resultMap/parameterMap basis, but a legacy database I'm
> using stores empty string rather than null for all string. The typeHandler
> seems like an easier solution as I can put it in the config file once and
> forget about it... Is there anything wrong doing it this way?
No, that's will do the job.
One remark, your typehandler can override iBatisNet's configuration for
string type.
Search a converstion named "NUMBER dbType - Double/Decimal .NET Type " in
the "user-cs" list.
I will try it returning Nothing/null.
>
> Thanks for the response.
> Mike --
> Cheers,
> Gilles
>
> <a href="http://www.amazon.com/gp/registry/6JCP7AORB0LE">Wish List</a>
Re: New ITypeHandler NullValue property
Posted by Michael Schall <mi...@gmail.com>.
I could do it on a resultMap/parameterMap basis, but a legacy database I'm
using stores empty string rather than null for all string. The typeHandler
seems like an easier solution as I can put it in the config file once and
forget about it... Is there anything wrong doing it this way?
I will try it returning Nothing/null.
Thanks for the response.
Mike
On 1/25/07, Gilles Bayon <ib...@gmail.com> wrote:
>
> It's always represent a .NET value.
> For example if I have a DateTime property with DateTime.Min as value, I
> will set paremeterMap property attribute nullValue="01/01/0001 00:00:00" to
> save null in db
> On a resultMap property the same nullValue="01/01/0001 00:00:00", will
> transform a database value null to DateTime.Min.
>
> Hopes this help.
> Just needs to read the doc
> http://ibatis.apache.org/docs/dotnet/datamapper/ch03s04.html#id357123
>
> You don't need to use a TypeHandler
>
> --
> Cheers,
> Gilles
>
> <a href="http://www.amazon.com/gp/registry/6JCP7AORB0LE">Wish List</a>
Re: New ITypeHandler NullValue property
Posted by Gilles Bayon <ib...@gmail.com>.
It's always represent a .NET value.
For example if I have a DateTime property with DateTime.Min as value, I will
set paremeterMap property attribute nullValue="01/01/0001 00:00:00" to save
null in db
On a resultMap property the same nullValue="01/01/0001 00:00:00", will
transform a database value null to DateTime.Min.
Hopes this help.
Just needs to read the doc
http://ibatis.apache.org/docs/dotnet/datamapper/ch03s04.html#id357123
You don't need to use a TypeHandler
--
Cheers,
Gilles
<a href="http://www.amazon.com/gp/registry/6JCP7AORB0LE">Wish List</a>