Class PersistenceException

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String END_INFO
      Tag ending extra identifiable/session info in message.
      static java.lang.String START_INFO
      Tag starting extra identifiable/session info in message.
    • Constructor Summary

      Constructors 
      Constructor Description
      PersistenceException()
      Constructs a new database runtime exception without a db connection and with null as its detail message.
      PersistenceException​(java.lang.String message)
      Constructs a new database runtime exception without a db connection with the specified detail message.
      PersistenceException​(java.lang.String message, java.lang.Throwable cause)
      Constructs a new database runtime exception without a db connection with the specified detail message and cause.
      PersistenceException​(java.lang.Throwable cause)
      Constructs a new database runtime exception without a db connection with the specified cause and a detail message of (cause==null ? null : cause.toString()) (which typically contains the class and detail message of cause).
      PersistenceException​(org.tentackle.misc.Identifiable identifiable)
      Constructs a new database runtime exception for a given db object with null as its detail message.
      PersistenceException​(org.tentackle.misc.Identifiable object, java.lang.String message)
      Constructs a new database runtime exception for a given db connection with the specified detail message.
      PersistenceException​(org.tentackle.misc.Identifiable object, java.lang.String message, java.lang.Throwable cause)
      Constructs a new database runtime exception for a given db connection with the specified detail message and cause.
      PersistenceException​(org.tentackle.misc.Identifiable object, java.lang.Throwable cause)
      Constructs a new database runtime exception for a given db connection with the specified cause and a detail message of (cause==null ? null : cause.toString()) (which typically contains the class and detail message of cause).
      PersistenceException​(Session session)
      Constructs a new database runtime exception for a given db connection with null as its detail message.
      PersistenceException​(Session session, java.lang.String message)
      Constructs a new database runtime exception for a given db connection with the specified detail message.
      PersistenceException​(Session session, java.lang.String message, java.lang.Throwable cause)
      Constructs a new database runtime exception for a given db connection with the specified detail message and cause.
      PersistenceException​(Session session, java.lang.Throwable cause)
      Constructs a new database runtime exception for a given db connection with the specified cause and a detail message of (cause==null ? null : cause.toString()) (which typically contains the class and detail message of cause).
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.RuntimeException createFromRemoteException​(java.lang.Object relatedObject, java.rmi.RemoteException remoteException)
      Creates a RuntimeException from a RemoteException.
      Returns the first RuntimeException in chain.
      static PersistenceException extractPersistenceException​(java.lang.Throwable e)
      Extracts the PersistenceException from an exception.
      org.tentackle.misc.Identifiable getIdentifiable()
      Gets the persistent object.
      java.lang.String getMessage()  
      Session getSession()
      Gets the session.
      protected void setIdentifiable​(org.tentackle.misc.Identifiable object)
      Sets the pdo.
      protected void setSession​(Session session)
      Sets the db.
      void updateDbObject​(org.tentackle.misc.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.
      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, 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

      • START_INFO

        public static final java.lang.String START_INFO
        Tag starting extra identifiable/session info in message.
        See Also:
        Constant Field Values
      • END_INFO

        public static final java.lang.String END_INFO
        Tag ending extra identifiable/session info in message.
        See Also:
        Constant Field Values
    • Constructor Detail

      • PersistenceException

        public PersistenceException​(Session session)
        Constructs a new database runtime exception for a given db connection with null as its detail message. The cause is not initialized, and may subsequently be initialized by a call to Throwable.initCause(java.lang.Throwable).
        Parameters:
        session - the session
      • PersistenceException

        public PersistenceException​(Session session,
                                    java.lang.String message)
        Constructs a new database runtime exception for a given db connection with the specified detail message. The cause is not initialized, and may subsequently be initialized by a call to Throwable.initCause(java.lang.Throwable).
        Parameters:
        session - the session
        message - the detail message. The detail message is saved for later retrieval by the getMessage() method.
      • PersistenceException

        public PersistenceException​(Session session,
                                    java.lang.String message,
                                    java.lang.Throwable cause)
        Constructs a new database runtime exception for a given db connection with the specified detail message and cause.

        Note that the detail message associated with cause is not automatically incorporated in this runtime exception's detail message.

        Parameters:
        session - the session
        message - the detail message (which is saved for later retrieval by the getMessage() method).
        cause - the cause (which is saved for later retrieval by the Throwable.getCause() method). (A null value is permitted, and indicates that the cause is nonexistent or unknown.)
        Since:
        1.4
      • PersistenceException

        public PersistenceException​(Session session,
                                    java.lang.Throwable cause)
        Constructs a new database runtime exception for a given db connection with the specified cause and a detail message of (cause==null ? null : cause.toString()) (which typically contains the class and detail message of cause). This constructor is useful for runtime exceptions that are little more than wrappers for other throwables.
        Parameters:
        session - the session
        cause - the cause (which is saved for later retrieval by the Throwable.getCause() method). (A null value is permitted, and indicates that the cause is nonexistent or unknown.)
        Since:
        1.4
      • PersistenceException

        public PersistenceException​(org.tentackle.misc.Identifiable identifiable)
        Constructs a new database runtime exception for a given db object with null as its detail message. The cause is not initialized, and may subsequently be initialized by a call to Throwable.initCause(java.lang.Throwable).
        Parameters:
        identifiable - the db object
      • PersistenceException

        public PersistenceException​(org.tentackle.misc.Identifiable object,
                                    java.lang.String message)
        Constructs a new database runtime exception for a given db connection with the specified detail message. The cause is not initialized, and may subsequently be initialized by a call to Throwable.initCause(java.lang.Throwable).
        Parameters:
        object - the object
        message - the detail message. The detail message is saved for later retrieval by the getMessage() method.
      • PersistenceException

        public PersistenceException​(org.tentackle.misc.Identifiable object,
                                    java.lang.String message,
                                    java.lang.Throwable cause)
        Constructs a new database runtime exception for a given db connection with the specified detail message and cause.

        Note that the detail message associated with cause is not automatically incorporated in this runtime exception's detail message.

        Parameters:
        object - the object
        message - the detail message (which is saved for later retrieval by the getMessage() method).
        cause - the cause (which is saved for later retrieval by the Throwable.getCause() method). (A null value is permitted, and indicates that the cause is nonexistent or unknown.)
        Since:
        1.4
      • PersistenceException

        public PersistenceException​(org.tentackle.misc.Identifiable object,
                                    java.lang.Throwable cause)
        Constructs a new database runtime exception for a given db connection with the specified cause and a detail message of (cause==null ? null : cause.toString()) (which typically contains the class and detail message of cause). This constructor is useful for runtime exceptions that are little more than wrappers for other throwables.
        Parameters:
        object - the object
        cause - the cause (which is saved for later retrieval by the Throwable.getCause() method). (A null value is permitted, and indicates that the cause is nonexistent or unknown.)
        Since:
        1.4
      • PersistenceException

        public PersistenceException()
        Constructs a new database runtime exception without a db connection and with null as its detail message. The cause is not initialized, and may subsequently be initialized by a call to Throwable.initCause(java.lang.Throwable).
      • PersistenceException

        public PersistenceException​(java.lang.String message)
        Constructs a new database runtime exception without a db connection with the specified detail message. The cause is not initialized, and may subsequently be initialized by a call to Throwable.initCause(java.lang.Throwable).
        Parameters:
        message - the detail message. The detail message is saved for later retrieval by the getMessage() method.
      • PersistenceException

        public PersistenceException​(java.lang.String message,
                                    java.lang.Throwable cause)
        Constructs a new database runtime exception without a db connection with the specified detail message and cause.

        Note that the detail message associated with cause is not automatically incorporated in this runtime exception's detail message.

        Parameters:
        message - the detail message (which is saved for later retrieval by the getMessage() method).
        cause - the cause (which is saved for later retrieval by the Throwable.getCause() method). (A null value is permitted, and indicates that the cause is nonexistent or unknown.)
        Since:
        1.4
      • PersistenceException

        public PersistenceException​(java.lang.Throwable cause)
        Constructs a new database runtime exception without a db connection with the specified cause and a detail message of (cause==null ? null : cause.toString()) (which typically contains the class and detail message of cause). This constructor is useful for runtime exceptions that are little more than wrappers for other throwables.
        Parameters:
        cause - the cause (which is saved for later retrieval by the Throwable.getCause() method). (A null value is permitted, and indicates that the cause is nonexistent or unknown.)
    • Method Detail

      • createFromRemoteException

        public static java.lang.RuntimeException createFromRemoteException​(java.lang.Object relatedObject,
                                                                           java.rmi.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​(java.lang.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 org.tentackle.misc.Identifiable getIdentifiable()
        Gets the persistent object.
        Returns:
        the object, null if exception is not related to an object
      • getMessage

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

        public void updateDbObject​(org.tentackle.misc.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
      • setIdentifiable

        protected void setIdentifiable​(org.tentackle.misc.Identifiable object)
        Sets the pdo.
        Parameters:
        object - the persistent object
      • setSession

        protected void setSession​(Session session)
        Sets the db.
        Parameters:
        session - the session