Don't log and rethrow exceptions in AbstractFlushingEventListener

Description

For a similar issue covering logging-and-rethrowing overall, see http://opensource.atlassian.com/projects/hibernate/browse/HB-1308. This issue covers a specific instance in order to minimize the impact on the codebase. However, I would be all for elimination of every instance of log-and-rethrow in the codebase.

In this particular instance, I have a table A with a foreign key referencing records in table B. In my user interface, I give the user the ability to delete records from table B. If the user attempts to delete a record from table B that is referred to in table A, the database throws an integrity constraint violation. This exception is caught in AbstractFlushingEventListener.performExecutions, logged, and rethrown. My code sees the exception and informs the user that the record cannot be deleted because it's already in use in the system. So the exception ends up showing up in my logs (from the log.error() statement in AbstractFlushingEventListener.performExecutions) even though I'm handling it properly. I would like the log.error() statement removed since the code propagates the exception. Attached is a patchfile.

I'm not including a test case because I feel the issue is so simplistic that one isn't necessary.

Environment

Hibernate 3.3.2.GA
Oracle Database 10.1.0.4.0
JDK 1.6.0_17

Activity

Show:
Gregg
September 24, 2010, 6:20 PM

Uploaded the correct patchfile

Gregg
September 24, 2010, 6:26 PM

An alternative solution is to use a chained exception via the following patch

Gail Badner
March 9, 2011, 10:20 PM

Fixed in git hibernate-core master and 3.6

Brett Meyer
March 7, 2014, 10:09 PM

Bulk closing tickets resolved in released versions

Assignee

Gail Badner

Reporter

Gregg

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Trivial
Configure