Class PersistenceException

java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.tentackle.common.TentackleRuntimeException
org.tentackle.session.PersistenceException
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
ConstraintException, LoginFailedException, NotFoundException, NotRemovableException, SessionClosedException

public class PersistenceException extends org.tentackle.common.TentackleRuntimeException
Database runtime exception.
Author:
harald
See Also:
  • Constructor Details

    • PersistenceException

      public PersistenceException(Session session)
      Constructs a new database runtime exception for a given session with null as its detail message.
      Parameters:
      session - the session
    • PersistenceException

      public PersistenceException(Session session, String message)
      Constructs a new database runtime exception for a given session with the specified detail message.
      Parameters:
      session - the session
      message - the detail message.
    • PersistenceException

      public PersistenceException(Session session, String message, Throwable cause)
      Constructs a new database runtime exception for a given session with the specified detail message and cause.
      Parameters:
      session - the session
      message - the detail message
      cause - the cause
    • PersistenceException

      public PersistenceException(Session session, Throwable cause)
      Constructs a new database runtime exception for a given session with the specified cause and a detail message of (cause==null ? null : cause.toString()).
      Parameters:
      session - the session
      cause - the cause
    • PersistenceException

      public PersistenceException(Identifiable identifiable)
      Constructs a new database runtime exception for a given identifiable with null as its detail message.
      Parameters:
      identifiable - the identifiable object
    • PersistenceException

      public PersistenceException(Identifiable object, String message)
      Constructs a new database runtime exception for a given identifiable with the specified detail message.
      Parameters:
      object - the identifiable
      message - the detail message.
    • PersistenceException

      public PersistenceException(Identifiable object, String message, Throwable cause)
      Constructs a new database runtime exception for a given identifiable with the specified detail message and cause.
      Parameters:
      object - the identifiable
      message - the detail message
      cause - the cause
    • PersistenceException

      public PersistenceException(Identifiable object, Throwable cause)
      Constructs a new database runtime exception for a given identifiable with the specified cause and a detail message of (cause==null ? null : cause.toString()).
      Parameters:
      object - the identifiable
      cause - the cause
    • PersistenceException

      public PersistenceException()
      Constructs a new database runtime exception without a session or identifiable and with null as its detail message.
    • PersistenceException

      public PersistenceException(String message)
      Constructs a new database runtime exception without a session or identifiable for the specified detail message.
      Parameters:
      message - the detail message.
    • PersistenceException

      public PersistenceException(String message, Throwable cause)
      Constructs a new database runtime exception without a session or identifiable with the specified detail message and cause.
      Parameters:
      message - the detail message
      cause - the cause
    • PersistenceException

      public PersistenceException(Throwable cause)
      Constructs a new database runtime exception without a session or identifiable with the specified cause and a detail message of (cause==null ? null : cause.toString()).
      Parameters:
      cause - the cause
  • Method Details

    • createFromRemoteException

      public static RuntimeException createFromRemoteException(Object relatedObject, RemoteException remoteException)
      Creates a RuntimeException from a RemoteException.
      Returns the first RuntimeException in chain. If the first non-RemoteException is not a RuntimeException, the exception is wrapped by a PersistenceException.
      Parameters:
      relatedObject - the optional related object, only used if remote cause is not a PersistenceException
      remoteException - the remote exception
      Returns:
      the runtime exception
    • extractPersistenceException

      public static PersistenceException extractPersistenceException(Throwable e)
      Extracts the PersistenceException from an exception.

      Scans the exception chain until it finds an PersistenceException.

      Parameters:
      e - the exception head
      Returns:
      the PersistenceException, null if none
    • getSession

      public Session getSession()
      Gets the session.
      Returns:
      the session
    • getIdentifiable

      public Identifiable getIdentifiable()
      Gets the persistent object.
      Returns:
      the object, null if exception is not related to an object
    • getMessage

      public String getMessage()
      Overrides:
      getMessage in class Throwable
    • updateDbObject

      public void updateDbObject(Identifiable object)
      Updates the pdo if not set so far.
      Used to add more info for exceptions thrown in a context where the pdo isn't known.
      Parameters:
      object - the persistent object