|
Version 4.8.0
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
ObjectThrowable
Exception
ServletException
hirondelle.web4j.model.AppException
hirondelle.web4j.database.DAOException
hirondelle.web4j.database.DuplicateException
public final class DuplicateException
Thrown when a uniqueness problem occurs in the datastore during an ADD or CHANGE operation.
This type of exception is singled out since it is so common. It allows
Actions to catch this specific kind of exception.
For relational databases, this exception should be thrown for INSERT
and UPDATE operations which may violate a UNIQUE or
PRIMARY KEY constraint, or similar item.
Db, DbTx, and TxTemplate will throw a DuplicateException
exception for SQLExceptions having an error code matching the
ErrorCodeForDuplicateKey configured in web.xml.
See web.xml for more information.
Action is calling a DAO method which may throw
a DuplicateException:
private void addSomething throws DAOException {
//this try..catch is needed only if the operation
//can have a duplicate problem
try {
dao.addSomething();
}
catch (DuplicateException ex){
addError("Cannot add. That item already exists.");
}
}
Note that if the operation cannot have a duplicate problem, then the Action should not attempt to catch DuplicateException.
Here is the DAO operation which may have a duplicate problem.
//It is highly recommended, but optional, to declare
//DuplicateException in this method header, to bring
//it to the attention of the caller
public addSomething() throws DAOException, DuplicateException {
//...elided
}
Again, if the operation cannot have a duplicate problem, then the DAO should not
declare a DuplicateException in its throws clause.
The Db.add(SqlId, Object[]) and Db.edit(SqlId, Object[]) methods can throw a
DuplicateException.
| Constructor Summary | |
|---|---|
DuplicateException(String aMessage,
Throwable aRootCause)
Constructor. |
|
| Method Summary |
|---|
| Methods inherited from class hirondelle.web4j.model.AppException |
|---|
add, add, add, getMessages, isEmpty, isNotEmpty, toString |
| Methods inherited from class ServletException |
|---|
getRootCause |
| Methods inherited from class Throwable |
|---|
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace |
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public DuplicateException(String aMessage,
Throwable aRootCause)
Arguments are passed to DAOException.DAOException(String, Throwable).
|
Version 4.8.0
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||