exception-handler

Use eclipselink.exception-handler to specify the TopLink exception handler class: a Java class that implements the org.eclipse.persistence.exceptions.ExceptionHandler interface and provides a default (zero-argument) constructor.

Values

Table 5-34 describes this persistence property's values.

Table 5-34 Valid Values for exception-handler

Value Description

ExceptionHandler class

Use the handleException method of the class, which takes a java.lang.RuntimeException, to:

  • Re-throw the exception

  • Throw a different exception

  • Retry the query or database operation.


Usage

The ExceptionHandler class name must be fully qualified by its package name.

Examples

Example 5-22 shows how to use this persistence property extension in the persistence.xml file.

Example 5-22 Using exception-handler in persistence.xml

<property name="eclipselink.exception-handler" value="my.package.MyExceptionHandler">

Example 5-23 shows how to use this extension in a property map

Example 5-23 Using exception-handler in a Property Map

import org.eclipse.persistence.config.PersistenceUnitProperties;propertiesMap.put(PersistenceUnitProperties.EXCEPTION_HANDLER_CLASS, "my.package.MyExceptionHandler");

See Also

For more information, see:

  • "orm.throw.exceptions"

  • "Sessions" in Understanding Oracle TopLink

  • "Managing and Diagnosing Problems" in Solutions Guide for Oracle TopLink