ConstraintViolationException logged at level ERROR instead of WARN or INFO
--------------------------------------------------------------------------
Key: HHH-3731
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3731
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.2.6
Environment: hibernate core jar specifies 3.2.6 in META-INF folder. database is
oracle 10.2. OS is Win XP
Reporter: Jonathan Amir
Priority: Minor
Attachments: stacktrace.txt
Please see this thread for an example and an explanation of the problem:
http://forums.hibernate.org/viewtopic.php?p=2258025&sid=cdcf98f3e9026...
Basically, it is a valid use-case for a developer to insert a record to the db and to try
and catch a ConstraintViolationException. Upon catching it, it should be the
developer's choice regarding what to do, how to recover, etc., and also how to log
it.
However, Hibernate logs the error before throwing it, and at log level ERROR, no less,
thus polluting the log files with superfluous messages. It is not practical to log
messages at this Level. The offending class is AbstractFlushingEventListener.java
(I'm attaching a stacktrace to illustrate).
Please reduce the log level of this message to WARN or INFO.
There's also a sort of philosophical argument for this request. Some may argue, like
in the reply in the linked thread above, that a constraint violation is an error, thus it
should be logged as one. However, that is an application-domain error, not a hibernate
error. Hibernate is a library, and as such it should conform to user's requirements.
First, it should use the ERROR level only to log real errors related to Hibernate's
functionality as a library. Secondly, it should aim to give the user maximum flexiblity
and control with regards to logging.
(Not withstanding the previous statement, logging application problems is, of course, very
helpful for debugging, but it should be at a lower log level)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira