/// <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));
        }
예제 #2
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>
 /// 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 flushing: " + ex.Message, null, ex.InnerException));
 }
예제 #4
0
 /// <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)
 {
 }
예제 #5
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));
 }
 /// <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);
     }
 }
예제 #7
0
        public static void ShowDbError(IWin32Window owner, ADOException e)
        {
            PostgresException detail = e.InnerException as PostgresException;

            KryptonMessageBox.Show(owner, detail?.Message ?? e.Message, Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
        }