com.jenkov.mrpersister.itf
Class PersistenceException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by com.jenkov.mrpersister.itf.PersistenceException
All Implemented Interfaces:
java.io.Serializable

public class PersistenceException
extends java.lang.Exception

This exception is the super type of all exceptions thrown in Mr. Persister. At present it is also the only exception thrown anywhere in the Mr. Persister API, but we may later throw subclasses so you can catch and handle the various exceptions more precisely. The interface won't be changed though, and still only throw this super type, PersistenceException.

Like any other exception PersistenceException can have a root cause (an exception) attached to it. In addition to this normal root cause a PersistenceException can have two other exceptions attached to it:

  1. A connection rollback exception
    If an exception is thrown during execution of a dao command in a transaction, and the connection.rollback() method throws an exception too, then the exception thrown by connection.rollback() is attached.
  2. A connection close exception
    If an exception is thrown from a dao command, and the connection.close() call throws an exception too, then the exception thrown from the connection.close() method is attached.


If an exception is thrown during connection.close() and no exception has been thrown earlier, then a PersistenceException will be thrown. This PersistenceException will not have a close exception attached since it is itself the close exception. This situation cannot occur with the rollback exception. The transaction is only rolled back if an exception is thrown during dao command execution, so there will always be a prior exception.

Author:
Jakob Jenkov, Jenkov Development
See Also:
Serialized Form

Field Summary
protected  java.sql.SQLException connectionCloseException
           
protected  java.sql.SQLException connectionRollbackException
           
 
Constructor Summary
PersistenceException()
           
PersistenceException(java.lang.String msg)
           
PersistenceException(java.lang.String msg, java.lang.Throwable throwable)
           
PersistenceException(java.lang.Throwable throwable)
           
 
Method Summary
 java.sql.SQLException getConnectionCloseException()
           
 java.sql.SQLException getConnectionRollbackException()
           
 void setConnectionCloseException(java.sql.SQLException connectionCloseException)
           
 void setConnectionRollbackException(java.sql.SQLException connectionRollbackException)
           
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

connectionRollbackException

protected java.sql.SQLException connectionRollbackException

connectionCloseException

protected java.sql.SQLException connectionCloseException
Constructor Detail

PersistenceException

public PersistenceException()

PersistenceException

public PersistenceException(java.lang.String msg)

PersistenceException

public PersistenceException(java.lang.String msg,
                            java.lang.Throwable throwable)

PersistenceException

public PersistenceException(java.lang.Throwable throwable)
Method Detail

getConnectionRollbackException

public java.sql.SQLException getConnectionRollbackException()

setConnectionRollbackException

public void setConnectionRollbackException(java.sql.SQLException connectionRollbackException)

getConnectionCloseException

public java.sql.SQLException getConnectionCloseException()

setConnectionCloseException

public void setConnectionCloseException(java.sql.SQLException connectionCloseException)