-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: How to stop an Exception being logged
PostPosted: Mon Mar 08, 2010 10:10 am 
Newbie

Joined: Mon Mar 08, 2010 10:02 am
Posts: 1
Hi,

I have code that does,
try {
lock = new MyHBN(id, new Date());
db.save(lock);
db.flush();
success = true;
} catch (HibernateException hex) {

The MyHBN contains a column that must be unique. If a unique violation occurs during the db.flush, the HibernateException is caught,
so I can correctly handle it.

but the following Error is still logged,
[#|2010-03-08T13:10:32.577+0000|INFO|sun-appserver2.1|javax.enterprise.system.stream.out|_ThreadID=23;_ThreadName=httpSSLWorkerThread-8080-4;|08 Mar 2010 13:10:32,571 WARN hibernate.util.JDBCExceptionReporter:100 - SQL Error: 1, SQLState: 23000
|#]

[#|2010-03-08T13:10:32.586+0000|INFO|sun-appserver2.1|javax.enterprise.system.stream.out|_ThreadID=23;_ThreadName=httpSSLWorkerThread-8080-4;|08 Mar 2010 13:10:32,579 ERROR hibernate.util.JDBCExceptionReporter:101 - [sunm][Oracle JDBC Driver][Oracle]ORA-00001: unique constraint (RICHARDA.SYS_C007034) violated

[#|2010-03-08T13:10:32.605+0000|INFO|sun-appserver2.1|javax.enterprise.system.stream.out|_ThreadID=23;_ThreadName=httpSSLWorkerThread-8080-4;|08 Mar 2010 13:10:32,587 ERROR event.def.AbstractFlushingEventListener:324 - Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:94)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1028)
...
Caused by: com.sun.sql.jdbc.base.BaseBatchUpdateException: [sunm][Oracle JDBC Driver][Oracle]ORA-00001: unique constraint (RICHARDA.SYS_C007034) violated


How can I stop those errors being logged?

Thanks


Top
 Profile  
 
 Post subject: Re: How to stop an Exception being logged
PostPosted: Mon Mar 08, 2010 12:05 pm 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Assuming that you are using log4j as logging system (=the most used),
you can define

Code:
log4j.logger.org.hibernate.event.def.AbstractFlushingEventListener=OFF
log4j.logger.org.hibernate.util.JDBCExceptionReporter=OFF


in your log4j-configuration file if you don't get errors logged from this classes.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.