spring.net db:provider?

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
aheydler
Posts: 5
Joined: Fri 18 Nov 2011 04:53

spring.net db:provider?

Post by aheydler » Fri 09 Dec 2011 02:21

Can someone provide an example or some hints on how to setup a spring.net db:provider config entry to allow dotConnect for Oracle to be used as the provider please?

The ORM being used is NH3.2

Works OK with Oracle's provider - just not seeing how to set it up for dotConnect.

TIA

Andreas

JomKippur
Posts: 17
Joined: Wed 31 Aug 2011 15:46

Post by JomKippur » Fri 16 Dec 2011 13:14

Code: Select all

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

<!--	- Database Provider definitions. -->
<objects xmlns='http&#58;//www.springframework.net'>
<object id="Devart.Data.Oracle" type="Spring.Data.Common.DbProvider, Spring.Data" singleton="false">
<constructor-arg name="dbMetaData">
<object type="Spring.Data.Common.DbMetadata">
<constructor-arg name="productName" value="Oracle, Oracle Data Provider V6.50.244.0"  />
<constructor-arg name="assemblyName" value="Devart.Data.Oracle, Version=6.50.244.0, Culture=neutral, PublicKeyToken=09af7300eec23701"/>
<constructor-arg name="connectionType" value="Devart.Data.Oracle.OracleConnection, Devart.Data.Oracle, Version=6.50.244.0, Culture=neutral, PublicKeyToken=09af7300eec23701"/>
<constructor-arg name="commandType" value="Devart.Data.Oracle.OracleCommand, Devart.Data.Oracle, Version=6.50.244.0, Culture=neutral, PublicKeyToken=09af7300eec23701"/>
<constructor-arg name="parameterType" value="Devart.Data.Oracle.OracleParameter, Devart.Data.Oracle, Version=6.50.244.0, Culture=neutral, PublicKeyToken=09af7300eec23701"/>
<constructor-arg name="dataAdapterType" value="Devart.Data.Oracle.OracleDataAdapter, Devart.Data.Oracle, Version=6.50.244.0, Culture=neutral, PublicKeyToken=09af7300eec23701"/>
<constructor-arg name="commandBuilderType" value="Devart.Data.Oracle.OracleCommandBuilder, Devart.Data.Oracle, Version=6.50.244.0, Culture=neutral, PublicKeyToken=09af7300eec23701"/>
<constructor-arg name="commandBuilderDeriveParametersMethod" value="DeriveParameters"/>
<constructor-arg name="parameterDbType" value="Devart.Data.Oracle.OracleDbType, Devart.Data.Oracle, Version=6.50.244.0, Culture=neutral, PublicKeyToken=09af7300eec23701"/>
<constructor-arg name="parameterDbTypeProperty" value="OracleDbType"/>
<constructor-arg name="parameterIsNullableProperty" value="IsNullable"/>
<constructor-arg name="parameterNamePrefix" value="&#58;"/>
<constructor-arg name="exceptionType" value="Devart.Data.Oracle.OracleException, Devart.Data.Oracle, Version=6.50.244.0, Culture=neutral, PublicKeyToken=09af7300eec23701"/>
<constructor-arg name="useParameterNamePrefixInParameterCollection" value="false"/>
<constructor-arg name="useParameterPrefixInSql" value="false"/>
<constructor-arg name="bindByName" value="true"/>
<!-- this is only true for .net 1.1 kept it here just in case we want to revert back to this strategy for
obtaining error codes-->
<constructor-arg name="errorCodeExceptionExpression" value="Code.ToString&#40;&#41;"/>

<property name="ErrorCodes.BadSqlGrammarCodes">
<value>900,903,904,917,936,942,17006</value>
</property>
<property name="ErrorCodes.InvalidResultSetAccessCodes">
<value>17003</value>
</property>
<property name="ErrorCodes.DataAccessResourceFailureCodes">
<value>17002,17447</value>
</property>
<property name="ErrorCodes.DataIntegrityViolationCodes">
<value>1,1400,1722,2291,2292</value>
</property>
<property name="ErrorCodes.CannotAcquireLockCodes">
<value>54</value>
</property>
<property name="ErrorCodes.CannotSerializeTransactionCodes">
<value>8177</value>
</property>
<property name="ErrorCodes.DeadlockLoserCodes">
<value>60</value>
</property>
</object>
</constructor-arg>
</object>
</objects>
For my project it works :)

HTH

JomKippur
Posts: 17
Joined: Wed 31 Aug 2011 15:46

Post by JomKippur » Fri 16 Dec 2011 13:26

And in your Spring configuration:

Code: Select all

<db:additionalProviders resource="assembly://MyAssembly/MyAssembly.MyNamespace/AdditionalProviders.xml"/>

Code: Select all

assembly://MyAssembly/MyAssembly.MyNamespace/AdditionalProviders.xml
- it's sent in previous post

and

Code: Select all

<entry key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/>
				<entry key="dialect" value="NHibernate.Dialect.Oracle10gDialect"/>
				<entry key="connection.driver_class" value="MyNamespace.Driver.DevartOracleDriver, MyNamespace"/>			
Def for MyNamespace.Driver.DevartOracleDriver:

Code: Select all

public class DevartOracleDriver : ReflectionBasedDriver, IEmbeddedBatcherFactoryProvider
	{
		public DevartOracleDriver()
			: base(
				"Devart.Data.Oracle",
				"Devart.Data.Oracle.NHibernate.NHibernateOracleConnection",
				"Devart.Data.Oracle.NHibernate.NHibernateOracleCommand")
		{
			OracleUtils.OracleClientCompatible = true;
		}

		public override bool UseNamedPrefixInSql
		{
			get { return true; }
		}

		public override bool UseNamedPrefixInParameter
		{
			get { return true; }
		}

		public override string NamedPrefix
		{
			get { return ":"; }
		}

		#region IEmbeddedBatcherFactoryProvider Members

		Type IEmbeddedBatcherFactoryProvider.BatcherFactoryClass
		{
			get { return typeof(OracleDataClientBatchingBatcherFactory); }
		}

		#endregion
	}

HTH

JomKippur
Posts: 17
Joined: Wed 31 Aug 2011 15:46

Post by JomKippur » Fri 16 Dec 2011 13:32


aheydler
Posts: 5
Joined: Fri 18 Nov 2011 04:53

Post by aheydler » Fri 16 Dec 2011 21:50

thank you kindly

Andreas

Tomasz.Kruk
Posts: 1
Joined: Tue 24 Apr 2012 12:59

Problem with exceptions mapping

Post by Tomasz.Kruk » Wed 25 Apr 2012 10:12

Hi,
In my project I use exactly the same configuration as is shown above.
Unfortunately I have some problems with exceptions. I get ORA-00001 from DB and I should get DataIntegrityViolationexception but I got UncategorizedDataAccessException instead. I can't find why this happens.
I have reviewed whole project and I couldn't find any bug.

Any suggestions what can cause this?

I appreciate any help. Thanks!

Shalex
Devart Team
Posts: 8088
Joined: Thu 14 Aug 2008 12:44

Re: spring.net db:provider?

Post by Shalex » Fri 27 Apr 2012 15:03

Tomasz.Kruk wrote:I get ORA-00001 from DB and I should get DataIntegrityViolationexception but I got UncategorizedDataAccessException instead.
Please contact the Spring.NET support team to find out the reason why their framework does not treat Oracle exceptions (returned by our provider) in a proper way.

Post Reply