[
http://issues.apache.org/jira/browse/IBATISNET-66?page=comments#action_65731 ]
Roberto Rabe commented on IBATISNET-66:
---------------------------------------
Had some slight issues with Oracle and MS OracleClient & ODP.NET 10g providers
and the new code in
IBatisNet.DataMapper.Configuration.ParameterMapping.ParameterMap.SetParameter():
if (parameterValue.GetType() != typeof(string) &&
parameterValue.GetType() != typeof(Guid) &&
!parameterValue.GetType().IsPrimitive)
{
value = ObjectProbe.GetPropertyValue(value, mapping.PropertyName);
if (value != null && value.GetType() == typeof(byte[]))
{
MemoryStream stream = new MemoryStream((byte[])value);
value = stream.ToArray();
}
}
Since the System.Type of the Order_Id column (resultMap tests) returned by
Oracle is Decimal, the check on on !IsPrimitive returns true. Then it mistakes
the object to be some sort of domain/business class named Decimal with a
property named value, and an exception is thrown when probing the object. The
code has been updated to do a check for Decimal and DateTime (since string and
Guid are already checked):
if (parameterValue.GetType() != typeof(string) &&
parameterValue.GetType() != typeof(Guid) &&
parameterValue.GetType() != typeof(Decimal) &&
parameterValue.GetType() != typeof(DateTime) &&
!parameterValue.GetType().IsPrimitive)
Code passed tests with Oracle & MS OracleClient | ODP.NET 10g; MySql & ByteFx;
MSSQL & SqlClient; PostgreSQL & Npgsql 0.7. Didn't get to check OLEDB and ODBC
though.
> #value# moniker not recognized when called something else like #ProductId#
> --------------------------------------------------------------------------
>
> Key: IBATISNET-66
> URL: http://issues.apache.org/jira/browse/IBATISNET-66
> Project: iBatis for .NET
> Type: Bug
> Reporter: Ron Grabowski
> Assignee: Gilles Bayon
> Priority: Minor
>
> The Dev Guide:
> http://prdownloads.sourceforge.net/ibatisnet/DevGuide.pdf?download
> has the following text on page 16:
> The name "value" is simply a placeholder, you can use another moniker if you
> like.
> That means it should be possible to re-write this:
> <!-- .NET -->
> <statement id=�insertProduct� parameter=�System.Integer�>
> select * from PRODUCT where PRD_ID = #value#
> </statement>
> as this:
> <!-- .NET -->
> <statement id=�insertProduct� parameter=�System.Integer�>
> select * from PRODUCT where PRD_ID = #ProductId#
> </statement>
> or even like this:
> <!-- .NET -->
> <statement id=�insertProduct�>
> select * from PRODUCT where PRD_ID = #ProductId#
> </statement>
> It looks like the dev guide mistakenly uses "parameter" instead of
> "parameterClass" in its example and "insertProduct" should be called
> "getProduct". Page 16, Example 22.
> When #ProductId# is used, "PreparedStatement" is logged but not "Parameters"
> or "Types". No exceptions are thrown.
> I think its important to keep the parameter name the user entered in their
> sql map instead of simply replacing it with "value":
> // GOOD
> PreparedStatement : [select * from PRODUCT where PRD_ID = ?]
> Parameters: [param0=['ProductId',19]]
> Types: [param0=[String, System.Int32]]
> // NOT SO GOOD
> PreparedStatement : [select * from PRODUCT where PRD_ID = ?]
> Parameters: [param0=['value',19]]
> Types: [param0=[String, System.Int32]]
> Here is another example showing #value# renamed to #year# in a <select>
> statement:
> http://tinyurl.com/886oq
> http://opensource.atlassian.com/confluence/oss/display/IBATIS/How+do+I+get+around+the+N+Plus+1+selects+problem%3F
--
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