You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ibatis.apache.org by "Gilles Bayon (JIRA)" <ib...@incubator.apache.org> on 2005/05/06 18:40:15 UTC

[jira] Commented: (IBATISNET-27) Oracle Issues

     [ http://issues.apache.org/jira/browse/IBATISNET-27?page=comments#action_64634 ]
     
Gilles Bayon commented on IBATISNET-27:
---------------------------------------

The fix for 
==============================================
if (propertyValue.GetType() == typeof(string) && propertyValue.ToString() == "" ) 
{ 
        //Manually changed "" to DbNull 
propertyValue = DBNull.Value; 
} 
=======================================================

is invalid. If I have, for another provider, a string.empty and want in database a "" as a result I have a DbNull and if my database field don't allowed null I get an error !

I will remove this patch from SVN.

A workAround is to created a new property to give the value for the DataBase
Ex :
public string DbString
{
get
  {
     if (_myRealString.Lenght==0)
         return null;
  }
}

> Oracle Issues
> -------------
>
>          Key: IBATISNET-27
>          URL: http://issues.apache.org/jira/browse/IBATISNET-27
>      Project: iBatis for .NET
>         Type: Improvement
>  Environment: vs 2003. Oracle 9i
>     Reporter: Ryan Yao
>     Assignee: Roberto Rabe
>      Fix For: DataMapper 1.2

>
> Thank you guys hard working on iBatis, I really like it. 
> There are some issues I found in DataMapper
> 1: Oracle has limitation on any parameter names. Let's say, if you have an object property like:
> Customer.Address.ProvinceOrState.Country.Id, then your sqlParamName will be 
> :Customer_Address_ProvinceOrState_Country_Id  
> Oracle doesn't like parameter longer than 30 characters.
> So what I can do is:
> public class PreparedStatementFactory
> .....
> private void CreateParametersForStatementText()
> ...
> change 
> sqlParamName = _parameterPrefix + paramName;}
> to something like:
> if (_session.DataSource.Provider.Name.Substring(0,6).ToLower().Equals("oracle"))
> {sqlParamName = _parameterPrefix + "param" + v_i;}
> else
> {sqlParamName = _parameterPrefix + paramName;}
> so the parameters to ":param0,:param2......".
> There probably there are better ways to solve this, this is the way I am using for now.
> 2. Oracle data adapter does not take empty string(it will throw exceptions if you do so), it takes Null/Nothing or strings(but no string.empty or "").So, in 
> public class ParameterMap
> .....
> public object GetValueOfProperty(object source, string propertyName)
> ......
> after
> if (propertyValue == null)
> {
> 	propertyValue = DBNull.Value; ;
> }
> Added:
> else if (propertyValue.GetType() == typeof(string) && propertyValue.ToString() == "" )
> {
>         //Manually changed "" to DbNull
> 	propertyValue = DBNull.Value;
> }
> Thanks....

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira