Java Persistence API (JPA) Extensions Reference for EclipseLink, Release 2.5
  Go To Table Of Contents


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


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.


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


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: