- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- org.tentackle.common.TentackleRuntimeException
-
- org.tentackle.session.PersistenceException
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
ConstraintException,LoginFailedException,NotFoundException,NotRemovableException,SessionClosedException
public class PersistenceException extends org.tentackle.common.TentackleRuntimeExceptionDatabase runtime exception.- Author:
- harald
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringEND_INFOTag ending extra identifiable/session info in message.static java.lang.StringSTART_INFOTag starting extra identifiable/session info in message.
-
Constructor Summary
Constructors Constructor Description PersistenceException()Constructs a new database runtime exception without a db connection and withnullas 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 withnullas 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 withnullas 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.RuntimeExceptioncreateFromRemoteException(java.lang.Object relatedObject, java.rmi.RemoteException remoteException)Creates a RuntimeException from aRemoteException.
Returns the first RuntimeException in chain.static PersistenceExceptionextractPersistenceException(java.lang.Throwable e)Extracts thePersistenceExceptionfrom an exception.org.tentackle.misc.IdentifiablegetIdentifiable()Gets the persistent object.java.lang.StringgetMessage()SessiongetSession()Gets the session.protected voidsetIdentifiable(org.tentackle.misc.Identifiable object)Sets the pdo.protected voidsetSession(Session session)Sets the db.voidupdateDbObject(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.
-
-
-
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 withnullas its detail message. The cause is not initialized, and may subsequently be initialized by a call toThrowable.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 toThrowable.initCause(java.lang.Throwable).- Parameters:
session- the sessionmessage- the detail message. The detail message is saved for later retrieval by thegetMessage()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
causeis not automatically incorporated in this runtime exception's detail message.- Parameters:
session- the sessionmessage- the detail message (which is saved for later retrieval by thegetMessage()method).cause- the cause (which is saved for later retrieval by theThrowable.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 sessioncause- the cause (which is saved for later retrieval by theThrowable.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 withnullas its detail message. The cause is not initialized, and may subsequently be initialized by a call toThrowable.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 toThrowable.initCause(java.lang.Throwable).- Parameters:
object- the objectmessage- the detail message. The detail message is saved for later retrieval by thegetMessage()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
causeis not automatically incorporated in this runtime exception's detail message.- Parameters:
object- the objectmessage- the detail message (which is saved for later retrieval by thegetMessage()method).cause- the cause (which is saved for later retrieval by theThrowable.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 objectcause- the cause (which is saved for later retrieval by theThrowable.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 withnullas its detail message. The cause is not initialized, and may subsequently be initialized by a call toThrowable.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 toThrowable.initCause(java.lang.Throwable).- Parameters:
message- the detail message. The detail message is saved for later retrieval by thegetMessage()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
causeis not automatically incorporated in this runtime exception's detail message.- Parameters:
message- the detail message (which is saved for later retrieval by thegetMessage()method).cause- the cause (which is saved for later retrieval by theThrowable.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 theThrowable.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 aRemoteException.
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 aPersistenceExceptionremoteException- the remote exception- Returns:
- the runtime exception
-
extractPersistenceException
public static PersistenceException extractPersistenceException(java.lang.Throwable e)
Extracts thePersistenceExceptionfrom 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:
getMessagein classjava.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
-
-