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 Summary
ConstructorsConstructorDescriptionConstructs a new database runtime exception without a session or identifiable and withnullas its detail message.PersistenceException(String message) Constructs a new database runtime exception without a session or identifiable for the specified detail message.PersistenceException(String message, Throwable cause) Constructs a new database runtime exception without a session or identifiable with the specified detail message and cause.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()).PersistenceException(Identifiable identifiable) Constructs a new database runtime exception for a given identifiable withnullas its detail message.PersistenceException(Identifiable object, String message) Constructs a new database runtime exception for a given identifiable with the specified detail message.PersistenceException(Identifiable object, String message, Throwable cause) Constructs a new database runtime exception for a given identifiable with the specified detail message and cause.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()).PersistenceException(Session session) Constructs a new database runtime exception for a given session withnullas its detail message.PersistenceException(Session session, String message) Constructs a new database runtime exception for a given session with the specified detail message.PersistenceException(Session session, String message, Throwable cause) Constructs a new database runtime exception for a given session with the specified detail message and cause.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()). -
Method Summary
Modifier and TypeMethodDescriptionstatic RuntimeExceptioncreateFromRemoteException(Object relatedObject, RemoteException remoteException) Creates a RuntimeException from aRemoteException.
Returns the first RuntimeException in chain.static PersistenceExceptionExtracts thePersistenceExceptionfrom an exception.Gets the persistent object.Gets the session.voidupdateDbObject(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 org.tentackle.common.TentackleRuntimeException
isTemporary, setTemporaryMethods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
PersistenceException
Constructs a new database runtime exception for a given session withnullas its detail message.- Parameters:
session- the session
-
PersistenceException
Constructs a new database runtime exception for a given session with the specified detail message.- Parameters:
session- the sessionmessage- the detail message.
-
PersistenceException
Constructs a new database runtime exception for a given session with the specified detail message and cause.- Parameters:
session- the sessionmessage- the detail messagecause- the cause
-
PersistenceException
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 sessioncause- the cause
-
PersistenceException
Constructs a new database runtime exception for a given identifiable withnullas its detail message.- Parameters:
identifiable- the identifiable object
-
PersistenceException
Constructs a new database runtime exception for a given identifiable with the specified detail message.- Parameters:
object- the identifiablemessage- the detail message.
-
PersistenceException
Constructs a new database runtime exception for a given identifiable with the specified detail message and cause.- Parameters:
object- the identifiablemessage- the detail messagecause- the cause
-
PersistenceException
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 identifiablecause- the cause
-
PersistenceException
public PersistenceException()Constructs a new database runtime exception without a session or identifiable and withnullas its detail message. -
PersistenceException
Constructs a new database runtime exception without a session or identifiable for the specified detail message.- Parameters:
message- the detail message.
-
PersistenceException
Constructs a new database runtime exception without a session or identifiable with the specified detail message and cause.- Parameters:
message- the detail messagecause- the cause
-
PersistenceException
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 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
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
Gets the session.- Returns:
- the session
-
getIdentifiable
Gets the persistent object.- Returns:
- the object, null if exception is not related to an object
-
getMessage
- Overrides:
getMessagein classThrowable
-
updateDbObject
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
-