At some point in my code hibernate sometimes throws an
LazyInitializationException. This is perfectly reasonable because the session is not always available. Because this is not really a problem I catch the exception and log a simple warning in my logfile or just ignore the case and continue.
Something like this:
Code:
try {
List<User> user = group.getUsers();
} catch (LazyInitializationException e) {
// ignore
}
Because I catch this exception and consider it to be harmless (within my code) I don't want my logfiles spoiled with useless stacktraces. Although I catch it and ignore it, Hibernate still logs the stacktraces which is really annoyng:
Code:
...
INFO: building session factory
Sep 9, 2006 3:19:34 PM org.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: Not binding factory to JNDI, no JNDI name configured
Sep 9, 2006 3:19:34 PM org.hibernate.LazyInitializationException <init>
SEVERE: illegal access to loading collection
org.hibernate.LazyInitializationException: illegal access to loading collection
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:341)
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
at org.hibernate.collection.AbstractPersistentCollection.readElementExistence(AbstractPersistentCollection.java:142)
...
Does anyone know why hibernate dumps stacktraces of exceptions that could possibly be catched later?