[SPRNET-779] NHibernateTransactionManager can not convert AdoAcessException Created: 23/Nov/07 Updated: 07/Dec/07 Resolved: 07/Dec/07
|Affects Version/s:||1.1 RC2|
|Reporter:||cagatay kalan||Assignee:||Mark Pollack|
|Remaining Estimate:||Not Specified|
|Time Spent:||Not Specified|
|Original Estimate:||Not Specified|
Windows XP SP2, Sql Server 2005
When you use OpenSessionInView module in a web application and use HibernateTransactionManager, you get "NullReferenceException" in response to a AdoException at "HibernateTransactionManager.ConvertAdoAccessException" method. The code i tried is as follows:
This is the dao method,
[Transaction(ReadOnly = false)]
I have copied the configuration from the Spring.Data.NHibernate.Northwind project in examples folder.
I checked the source files and I think that, because there is an existing transaction HibernateTemplate does not flush the session. So the exception is not thrown from HibernateTemplate. At the end of the transaction, HibernateTransactionManager tries to commit the transaction and NullReferenceException occurs because "adoExceptionTranslator" field of the transaction manager is null. The documentation does not tell about how to set an AdoExceptionTranslator to this field. I think the main problem is that, if you use HibernateTransactionManager, HibernateTemplate's error handling becomes useless.
I changed the getter of "AdoExceptionTranslator" in "HibernateTransactionManager" as the following,
public IAdoExceptionTranslator AdoExceptionTranslator
which i copied from HibernateTemplate. Now the AdoException is being converted.
|Comment by Mark Pollack [ 26/Nov/07 ]|
Hi, Thanks for reporting this. The same issue was reported a little while ago and it is now fixed. See