Hola Fabio,
Muchas gracias por responder. Con respecto a tu pregunta, significa
que la excepción no esta pasando por la clase que implementa la
interfaz ISQLExceptionConverter y la cual fue configurada en el
archivo de configuracion de NHibernate.
# Recibo la siguiente excepcion:
<EXCEPTION>
ErrorCode: -2146232060
Number: 547
Message:
The DELETE statement conflicted with the REFERENCE constraint
"FK_Pharmacy_City". The conflict occurred in database "Testing", table
"dbo.Pharmacy", column 'City_Id'.
The statement has been terminated.
</EXCEPTION>
# Para controlarla, hago lo siguiente:
# Implementacion de ISQLExceptionConverter
namespace Testing.DrugstoreSales.DataAccessLayer.ExceptionManagement
{
public class MsSqlExceptionManager : ISQLExceptionConverter
{
#region ISQLExceptionConverter Members
public Exception Convert(AdoExceptionContextInfo exInfo)
{
var sqle =
ADOExceptionHelper.ExtractDbException(exInfo.SqlException) as
SqlException;
if (sqle != null)
{
switch (sqle.Number)
{
case 547:
return new
ConstraintViolationException(exInfo.Message,
sqle.InnerException, exInfo.Sql, null);
case 208:
return new SQLGrammarException(exInfo.Message,
sqle.InnerException, exInfo.Sql);
case 3960:
return new
StaleObjectStateException(exInfo.EntityName, exInfo.EntityId);
}
}
return
SQLStateConverter.HandledNonSpecificException(exInfo.SqlException,
exInfo.Message, exInfo.Sql);
}
#endregion
}
}
# Configuracion:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" >
<session-factory name="NHibernate.Test">
<property
name="sql_exception_converter">Testing.DrugstoreSales.DataAccessLayer.ExceptionManagement.MsSqlExceptionManager,
Testing.DrugstoreSales.DataAccessLayer</property>
<property
name="connection.driver_class">NHibernate.Driver.SqlClientDriver</
property>
<property name="connection.connection_string">
Server=devhome\sql2k8;initial catalog=Testing;user
id=sa;password=######
</property>
<property name="adonet.batch_size">10</property>
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<property name="dialect">NHibernate.Dialect.MsSql2008Dialect</
property>
<property name="use_outer_join">true</property>
<property name="command_timeout">60</property>
<property name="query.substitutions">true 1, false 0, yes 'Y', no
'N'</property>
<property
name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory,
NHibernate.ByteCode.LinFu</property>
<mapping assembly="Testing.DrugstoreSales.DataAccessLayer" />
</session-factory>
</hibernate-configuration>
# Pero, despues hacer todo esto, sigo sin poder controlar la excepcion
antes mencionada.
Nuevamente, muchas gracias de antemano.
--
Para escribir al Grupo, hágalo a esta dirección:
[email protected]
Para más, visite: http://groups.google.com/group/NHibernate-Hispano