You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ibatis.apache.org by "Bob Hanson (JIRA)" <ib...@incubator.apache.org> on 2006/11/30 20:55:20 UTC
[jira] Created: (IBATISNET-197) Nullable throws an
exception instead of inserting null into Sql Server Money columns
Nullable<Decimal> throws an exception instead of inserting null into Sql Server Money columns
---------------------------------------------------------------------------------------------
Key: IBATISNET-197
URL: http://issues.apache.org/jira/browse/IBATISNET-197
Project: iBatis for .NET
Issue Type: Bug
Components: DataMapper
Environment: Sql Server 2000
Reporter: Bob Hanson
Currently using the HEAD revision.
When trying to map a null value from a property declared as Nullable<Decimal>, iBatis is throwing the exception shown below.
>From stepping into the code, it appears to me that the problem relates to how null parameters are created. They seem to keep most of their default values. The System.Data.SqlClient.SqlParameter contains the following:
DbType = String
SqlDbType = NVarChar
SqlValue = Null (but type is System.Data.SqlTypes.SqlString)
Value = object (System.DBNull)
This works fine for Integers, DateTime, Floats, etc. (and even Decimal) because they can be implicity converted from NVarChar as shown in the chart at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_ca-co_2f3o.asp
But converting from NVarChar to Money (which according to the iBatis documentation is mapped from the .Net Decimal type) throws an exception. I assume this is because (as the chart referenced above shows) it requires an Explicit conversion.
Is it possible for iBatis to retrieve and set the proper type information even when the value is null?
System.Data.SqlClient.SqlException was unhandled
Message="Implicit conversion from data type nvarchar to money is not allowed. Use the CONVERT function to run this query."
Source=".Net SqlClient Data Provider"
ErrorCode=-2146232060
Class=16
LineNumber=0
Number=257
Procedure="rec_Insert_Recording_Package"
Server="PMNSQL01\\CIT_USR_SQL"
State=2
StackTrace:
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteScalar()
at IBatisNet.DataMapper.Commands.DbCommandDecorator.System.Data.IDbCommand.ExecuteScalar() in C:\ibatis\trunk\cs\mapper\IBatisNet.DataMapper\Commands\DbCommandDecorator.cs:line 164
at IBatisNet.DataMapper.MappedStatements.MappedStatement.ExecuteInsert(ISqlMapSession session, Object parameterObject) in C:\ibatis\trunk\cs\mapper\IBatisNet.DataMapper\MappedStatements\MappedStatement.cs:line 895
at IBatisNet.DataMapper.SqlMapper.Insert(String statementName, Object parameterObject) in C:\ibatis\trunk\cs\mapper\IBatisNet.DataMapper\SqlMapper.cs:line 1318
--
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