Inheritance: NHibernate.HibernateException
Esempio n. 1
0
 /// <summary>
 /// Converts the ADO.NET access exception to an appropriate exception from the
 /// <code>org.springframework.dao</code> hierarchy. Can be overridden in subclasses.
 /// </summary>
 /// <param name="ex">ADOException that occured, wrapping underlying ADO.NET exception.</param>
 /// <returns>
 /// the corresponding DataAccessException instance
 /// </returns>
 protected virtual DataAccessException ConvertAdoAccessException(ADOException ex)
 {
     return SessionFactoryUtils.ConvertAdoAccessException(AdoExceptionTranslator, ex);         
 }
 /// <summary>
 /// Converts the ADO.NET access exception to an appropriate exception from the
 /// <code>org.springframework.dao</code> hierarchy. Can be overridden in subclasses.
 /// </summary>
 /// <param name="ex">ADOException that occured, wrapping underlying ADO.NET exception.</param>
 /// <returns>
 /// the corresponding DataAccessException instance
 /// </returns>
 protected virtual DataAccessException ConvertAdoAccessException(ADOException ex)
 {
     string sqlString = (ex.SqlString != null)
         ? ex.SqlString.ToString()
         : string.Empty;
         return AdoExceptionTranslator.Translate(
             "Hibernate operation: " + ex.Message, sqlString, ex.InnerException);
 }
Esempio n. 3
0
 /// <summary>
 /// Converts a Hibernate ADOException to a Spring DataAccessExcption, extracting the underlying error code from 
 /// ADO.NET.  Will extract the ADOException Message and SqlString properties and pass them to the translate method
 /// of the provided IAdoExceptionTranslator.
 /// </summary>
 /// <param name="translator">The IAdoExceptionTranslator, may be a user provided implementation as configured on
 /// HibernateTemplate.
 /// </param>
 /// <param name="ex">The ADOException throw</param>
 /// <returns>The translated DataAccessException or UncategorizedAdoException in case of an error in translation
 /// itself.</returns>
 public static DataAccessException ConvertAdoAccessException(IAdoExceptionTranslator translator, ADOException ex)
 {
     try
     {
         string sqlString = (ex.SqlString != null)
                                ? ex.SqlString.ToString()
                                : string.Empty;
         return translator.Translate(
             "Hibernate operation: " + ex.Message, sqlString, ex.InnerException);
     } catch (Exception e)
     {
         log.Error("Exception thrown during exception translation. Message = [" + e.Message + "]", e);
         log.Error("Exception that was attempted to be translated was [" + ex.Message + "]", ex);                
         if (ex.InnerException != null)
         {
             log.Error("  Inner Exception was [" + ex.InnerException.Message + "]", ex.InnerException);
         }
         throw new UncategorizedAdoException(e.Message, "", "", e);
     }
 }
 /// <summary>
 /// Convert the given ADOException to an appropriate exception from the
 /// the Spring.Dao hierarchy. Can be overridden in subclasses.
 /// </summary>
 /// <param name="ex">The ADOException that occured, wrapping the underlying
 /// ADO.NET thrown exception.</param>
 /// <param name="translator">The translator to convert hibernate ADOExceptions.</param>
 /// <returns>
 /// The corresponding DataAccessException instance
 /// </returns>
 protected virtual DataAccessException ConvertAdoAccessException(ADOException ex, IAdoExceptionTranslator translator)
 {
     return translator.Translate("Hibernate flusing: " + ex.Message, null, ex.InnerException);
 }
 /// <summary>
 /// Creates a new instance of the
 /// <see cref="HibernateAdoException"/> class.
 /// </summary>
 /// <param name="message">
 /// A message about the exception.
 /// </param>
 /// <param name="rootCause">
 /// The root exception from the underlying data access API - ADO.NET
 /// </param>        
 public HibernateAdoException( string message, ADOException rootCause )
     : base(message, rootCause)
 {
 }
Esempio n. 6
0
 /// <summary>
 /// Converts the ADO.NET access exception to an appropriate exception from the
 /// <code>org.springframework.dao</code> hierarchy. Can be overridden in subclasses.
 /// </summary>
 /// <param name="ex">ADOException that occured, wrapping underlying ADO.NET exception.</param>
 /// <returns>
 /// the corresponding DataAccessException instance
 /// </returns>
 protected virtual DataAccessException ConvertAdoAccessException(ADOException ex) 
 {
         return AdoExceptionTranslator.Translate(
             "Hibernate operation: " + ex.Message, null, ex.InnerException);            
 }