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 Roberto R <ro...@gmail.com> on 2005/05/17 07:09:21 UTC

RE: ibatisnet and postgresql with Npgsql7.0 beta5 has some error

This is a reply to an old mail from March 24...

Npgsql tests were added to SVN recently. Anyway, there was an issue for 
Npgsql with the sqlParameter.dbType. The issue moved from the place 
identified in the email to a logging statement after some refactoring done 
in the last couple of months. It was fixed over the weekend.

Also note that in the code provided, the resultClass is a Hashtable. Npgsql 
returns the keys in lowercase (vs uppercase for Oracle!) in case you get an 
issue with the name/key not being found.

Roberto

 hi all:


when i run to this,it throw
System.NullReferenceException;

detail is below:
in file
"IBatisNet.DataMapper\MappedStatements\MappedStatement.cs"
// With a ParameterMap, we could specify the
ParameterDbTypeProperty
if (_statement.ParameterMap != null)
{
if
(request.ParameterMap.GetProperty(i).DbType.Length >0)
{
string dbTypePropertyName =
session.DataSource.Provider.ParameterDbTypeProperty;


ObjectProbe.SetPropertyValue(parameterCopy,
dbTypePropertyName, ObjectProbe.
GetPropertyValue(sqlParameter, dbTypePropertyName));
}
else
{
parameterCopy.DbType =
sqlParameter.DbType; 
//throw
System.NullReferenceException
// if i comment
"parameterCopy.DbType = sqlParameter.DbType; ",It is
run right;
// now parameterCopy.DbType
is String
}
}
else
{
parameterCopy.DbType = sqlParameter.
DbType;  //System.NullReferenceException
}

Test.xml
<?xml version="1.0" encoding="UTF-8" ?>

<sqlMap namespace="TestPg"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<http://www.w3.org/2001/XMLSchema-instance%22>;

xsi:noNamespaceSchemaLocation="..\..\Nausicaa.Framework.Dal\Schemas\SqlMap.x
sd">

<statements>

<select id="SelectTestPg" resultClass="Hashtable"
parameterClass="Hashtable">
select * from pg_tables
where schemaname=#schema#
</select>

</statements>

</sqlMap>

in file providers.config 
added:
<provider
name="PgSql"
description="PostgreSql provider"
enabled="true"
assemblyName="Npgsql, Version=0.7.0.0 <http://0.7.0.0>,
Culture=neutral,
PublicKeyToken="
connectionClass="Npgsql.NpgsqlConnection" 
commandClass="Npgsql.NpgsqlCommand"
parameterClass="Npgsql.NpgsqlParameter"
parameterDbTypeClass="NpgsqlTypes.NpgsqlDbType"
parameterDbTypeProperty="NpgsqlDbType"
dataAdapterClass="Npgsql.NpgsqlDataAdapter"
commandBuilderClass="Npgsql.NpgsqlCommandBuilder"
usePositionalParameters = "false" 
useParameterPrefixInSql = "true"
useParameterPrefixInParameter =
"true" 
parameterPrefix=":"
/>


in file SqlMap.config

<?xml version="1.0" encoding="utf-8"?>
<sqlMapConfig
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<http://www.w3.org/2001/XMLSchema-instance%22>;
xsi:noNamespaceSchemaLocation="SqlMapConfig.xsd">
<settings>
<setting useStatementNamespaces="false"/>
<setting cacheModelsEnabled="true"/>
</settings>

<database> 
<provider name="PgSql"/>
<dataSource name="PgSql"
connectionString="Server=127.0.0.1 <http://127.0.0.1>;Port=5432;User
Id=postgres;Password=postgres;Database=resource"/>
</database>

<sqlMaps>
<sqlMap resource="Maps\Test.xml"/>
</sqlMaps>

</sqlMapConfig>


my software : 
winxp + sp2,postgresql 8.01,Npgsql7.0 beta5
ibatis is "iBatisNet-src.458.zip" download from
sourceforge.net <http://sourceforge.net>


thanks a lot!