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 2006/01/02 05:28:34 UTC

TypeHandlers for "System.Nullable(Of" fails with custom types

I am trying to get generics to work using custom type handlers.  I have 
it working with simple "known" types.  For example, adding a handler for 
a Nullable(Of DateTime) would look something like this...

<typeHandler

type="System.Nullable`1[[System.DateTime]]"

      dbType="datetime"

      
callback="ATG.Database.TypeHandlers.NullableDateTimeTypeHandlerCallback, 
ATG.Database"/>
 

This works great.  If you have to further specify the generic type, 
ibatis runs into problems.  For example

<typeHandler

      type="System.Nullable`1[[ATG.Money, ATG.Money]]"

      
callback="ATG.Database.TypeHandlers.NullableMoneyTypeHandlerCallback, 
ATG.Database"/> 

This fails inside the function SplitTypeAndAssemblyNames.  The function 
simply splits on the ',' to find the dll to load.  If I change this 
function to check if it is a generic type string it works fine.

      if (typeAssemblyIndex < 0 || originalTypeName.Contains("`1[[")) 

Is there an issue doing this?  If not can it be added to the core code?

Thanks
Michael

Re: TypeHandlers for "System.Nullable(Of" fails with custom types

Posted by Gilles Bayon <ib...@gmail.com>.
Hi Michael and Happy new year

You can create an issue in JIRA and attach a patch.

Thanks
-Gilles

On 1/2/06, Michael Schall <mi...@gmail.com> wrote:
>
> I am trying to get generics to work using custom type handlers.  I have
> it working with simple "known" types.  For example, adding a handler for
> a Nullable(Of DateTime) would look something like this...
>
> <typeHandler
>
> type="System.Nullable`1[[System.DateTime]]"
>
>      dbType="datetime"
>
>
> callback="ATG.Database.TypeHandlers.NullableDateTimeTypeHandlerCallback,
> ATG.Database"/>
>
>
> This works great.  If you have to further specify the generic type,
> ibatis runs into problems.  For example
>
> <typeHandler
>
>      type="System.Nullable`1[[ATG.Money, ATG.Money]]"
>
>
> callback="ATG.Database.TypeHandlers.NullableMoneyTypeHandlerCallback,
> ATG.Database"/>
>
> This fails inside the function SplitTypeAndAssemblyNames.  The function
> simply splits on the ',' to find the dll to load.  If I change this
> function to check if it is a generic type string it works fine.
>
>      if (typeAssemblyIndex < 0 || originalTypeName.Contains("`1[["))
>
> Is there an issue doing this?  If not can it be added to the core code?
>
> Thanks
> Michael
>