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 ni...@bnpparibas.com on 2006/01/11 19:28:46 UTC
Ibatis 1.3.0 / ODP 10g : NUMBER dbType - Double/Decimal .NET Type
Hi
I am migrating my application from MIcrosoft Oracle Provider
(System.Data.OracleClient) to ODP 10.0.4 (Oracle.DataAccess). and I
experiment some problems with NUMBER dbType.
According to the ODP Documentation, NUMBER should be read with the
OracleDataAdapter.GetDecimal() method and not
OracleDataAdapter.GetDouble(). With MS Provider, GetDouble works propoerly
Unfortunately, all my C# objects use double type. with MS Provider, I let
the AutoMapReader map the query result into my object properties. But with
ODP, it does not work anymore :( Indeed, The AutoMapReader still use
GetDouble.
So, Can Ibatis convert decimal to double for me at the mapping step ? Do I
write a Custom Type Handlers ? or is the any other solution more clever ?
Obviously, I can replace in my code all double type to Decimal type, and
add everywhere some Convert.ToDouble to avoid interface modfication but is
is quite boring.
Regards
This message and any attachments (the "message") is
intended solely for the addressees and is confidential.
If you receive this message in error, please delete it and
immediately notify the sender. Any use not in accord with
its purpose, any dissemination or disclosure, either whole
or partial, is prohibited except formal approval. The internet
can not guarantee the integrity of this message.
BNP PARIBAS (and its subsidiaries) shall (will) not
therefore be liable for the message if modified.
---------------------------------------------
Ce message et toutes les pieces jointes (ci-apres le
"message") sont etablis a l'intention exclusive de ses
destinataires et sont confidentiels. Si vous recevez ce
message par erreur, merci de le detruire et d'en avertir
immediatement l'expediteur. Toute utilisation de ce
message non conforme a sa destination, toute diffusion
ou toute publication, totale ou partielle, est interdite, sauf
autorisation expresse. L'internet ne permettant pas
d'assurer l'integrite de ce message, BNP PARIBAS (et ses
filiales) decline(nt) toute responsabilite au titre de ce
message, dans l'hypothese ou il aurait ete modifie.
Re: Ibatis 1.3.0 / ODP 10g : NUMBER dbType - Double/Decimal .NET Type
Posted by Ron Grabowski <ro...@yahoo.com>.
This will automatically convert to/from C#'s DateTime.MinValue to NULL.
public class NullDateTimeTypeHandlerCallback : ITypeHandlerCallback
{
public object ValueOf(string nullValue)
{
return nullValue;
}
public object GetResult(IResultGetter getter)
{
if (getter.Value.Equals(System.DBNull.Value))
{
return DateTime.MinValue;
}
else
{
return getter.Value;
}
}
public void SetParameter(IParameterSetter setter, object parameter)
{
if (parameter.Equals(DateTime.MinValue))
{
setter.Value = System.DBNull.Value;
}
else
{
setter.Value = parameter;
}
}
}
<typeHandlers>
<typeHandler
type="DateTime"
callback="Company.Project.NullDateTimeTypeHandlerCallback" />
</typeHandlers>
--- Gilles Bayon <ib...@gmail.com> wrote:
> Bonjour Nicolas
>
> The best solution is to use a custom type handler that overrides
> IBatisNet's
> DecimalTypeHandler
>
> <typeHandlers>
> <typeHandler
> type="System.Decimal"
> handler="CustomDoubleTypeHanlder" />
> </typeHandlers> (in SqlMap.config)
>
> Ron use such a solution to overrides IBatisNet's DateTimeTypeHandler.
>
> Cheers
> -Gilles
>
> On 1/11/06, nicolas.theron@bnpparibas.com
> <ni...@bnpparibas.com>
> wrote:
> >
> >
> > Hi
> >
> > I am migrating my application from MIcrosoft Oracle Provider
> > (System.Data.OracleClient) to ODP 10.0.4 (Oracle.DataAccess). and
> I
> > experiment some problems with NUMBER dbType.
> >
> > According to the ODP Documentation, NUMBER should be read with the
> > OracleDataAdapter.GetDecimal() method and not
> > OracleDataAdapter.GetDouble(). With MS Provider, GetDouble works
> propoerly
> >
> > Unfortunately, all my C# objects use double type. with MS Provider,
> I let
> > the AutoMapReader map the query result into my object properties.
> But with
> > ODP, it does not work anymore :( Indeed, The AutoMapReader still
> use
> > GetDouble.
> >
> > So, Can Ibatis convert decimal to double for me at the mapping step
> ? Do I
> > write a Custom Type Handlers ? or is the any other solution more
> clever ?
> >
> > Obviously, I can replace in my code all double type to Decimal
> type, and
> > add everywhere some Convert.ToDouble to avoid interface modfication
> but is
> > is quite boring.
> >
> > Regards
> >
>
Re: Ibatis 1.3.0 / ODP 10g : NUMBER dbType - Double/Decimal .NET Type
Posted by Gilles Bayon <ib...@gmail.com>.
Bonjour Nicolas
The best solution is to use a custom type handler that overrides IBatisNet's
DecimalTypeHandler
<typeHandlers>
<typeHandler
type="System.Decimal"
handler="CustomDoubleTypeHanlder" />
</typeHandlers> (in SqlMap.config)
Ron use such a solution to overrides IBatisNet's DateTimeTypeHandler.
Cheers
-Gilles
On 1/11/06, nicolas.theron@bnpparibas.com <ni...@bnpparibas.com>
wrote:
>
>
> Hi
>
> I am migrating my application from MIcrosoft Oracle Provider
> (System.Data.OracleClient) to ODP 10.0.4 (Oracle.DataAccess). and I
> experiment some problems with NUMBER dbType.
>
> According to the ODP Documentation, NUMBER should be read with the
> OracleDataAdapter.GetDecimal() method and not
> OracleDataAdapter.GetDouble(). With MS Provider, GetDouble works propoerly
>
> Unfortunately, all my C# objects use double type. with MS Provider, I let
> the AutoMapReader map the query result into my object properties. But with
> ODP, it does not work anymore :( Indeed, The AutoMapReader still use
> GetDouble.
>
> So, Can Ibatis convert decimal to double for me at the mapping step ? Do I
> write a Custom Type Handlers ? or is the any other solution more clever ?
>
> Obviously, I can replace in my code all double type to Decimal type, and
> add everywhere some Convert.ToDouble to avoid interface modfication but is
> is quite boring.
>
> Regards
>