Ok, using oracle's number(9) type solved the casting problem
(number(10) or bigger causes a type cast exception, which is reasoneable)

 I still have the "strings become null",

 interestingly number(9) (c# int types), and Date (c# DateTime)
get inserted correctly, so far, oracle varchar2 (c# strings)
are problematic (they are saved as null in the DB)...


-----Original Message-----
From: Ron Grabowski [mailto:[EMAIL PROTECTED] 
Sent: Thursday, April 21, 2005 1:27 PM
To: ibatis-user-cs@incubator.apache.org
Subject: Re: problems with param mapping, and params becoming null on oracle

>          SqlMapper m = Mapper.get();
> 
>          m.BeginTransaction();
> 
>          Usager u1 = new Usager();
> 
>          u1.Nom = "Popo";
> 
>          u1.NomUsager = "popo1212";
> 
>          u1.Prenom = "zozo";
> 
>          m.Insert("InsertUsager", u1);
> 
>          m.CommitTransaction();

FYI, there is a good base class for IBatisNet if you want to start out
doing basic INSERT, SELECTS, etc. We use this class in all of our
projects. It keeps classes that extend it nice and tidy:

http://tinyurl.com/8fl5f 
http://svn.apache.org/repos/asf/incubator/ibatis/trunk/cs/npetshop/NPetshop.
Persistence/MapperDao/BaseSqlMapDao.cs

Sample usage:

public Insert(Usager usager)
{
 if (usager == null)
 {
  throw new ArgumentNullException("usager");
 }

 try
 {
  return (int)ExecuteInsert("InsertUsager", usager);
 }
 catch(IBatisNetException ex)
 {
  // TODO: throw application specific exception
 }
}

Have you tried using the transactions ala C#'s using syntax as
described here:

http://tinyurl.com/b5wwg
http://svn.apache.org/repos/asf/incubator/ibatis/trunk/cs/mapper/IBatisNet.D
ataMapper/ChangeLog.txt

using ( IDalSession session = sqlMap.BeginTransaction() )
{
...db operations...
session.Complete(); // Commit
}

The NUnit test case that shows more examples:

http://tinyurl.com/8yvqu
http://svn.apache.org/repos/asf/incubator/ibatis/trunk/cs/mapper/IBatisNet.D
ataMapper.Test/NUnit/SqlMapTests/TransactionTest.cs

>  the oracle type 'number', won't map to either C# int or long 

According to this link:

http://tinyurl.com/9h222
http://issues.apache.org/jira/browse/IBATISNET-27#action_61688

.Net may be interpreting those as decimals.

The tests cases for Oracle databases:

http://tinyurl.com/9pveh
http://svn.apache.org/repos/asf/incubator/ibatis/trunk/cs/mapper/IBatisNet.D
ataAccess.Test/Scripts/Oracle/account-init.sql

use INTEGER or NUMBER(x) (where x is a number like 6, 10, 20, etc.) to
map database primary keys to System.Int32.

Here are the test cases for calling an insert statement for an Oracle
database and retrieving a primary key back as an int:

http://tinyurl.com/datft
http://svn.apache.org/repos/asf/incubator/ibatis/trunk/cs/mapper/IBatisNet.D
ataMapper.Test/NUnit/SqlMapTests/Oracle/StatementTest.cs

The version in source control has improved logging to show statements
being sent to the database. Perhaps you could build against that for a
while to verify the correct data is being sent to the database. If you
alreaddy have SVN installed, the following line will get the latest
version from source control and place it in a directory called
IBatisNet-svn:

svn co
http://svn.apache.org/repos/asf/incubator/ibatis/trunk/cs/mapper/
IBatisNet-svn

You should be able to double-click on the IBatisNet.sln file and build.

Please post if you any more questions. I've been using IBatisNet
without issue for the past several months against a Sql Server 2000
database, Access database (I think there are 2 people using Access
now!), and I've seen it work against an Oracle 9 database.

- Ron

Reply via email to