0

hibernate exceptions

asked 2006-12-29 14:12:14 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4077358

By: cmaniac

Hi, all of you...

a short question (... hope easy solution), there is a way to catch hibernate exceptions in my own code? I mean, I have try-catch clausules in a class that works directly with hibernate

session = HibernateUtil.getSessionFactory().getCurrentSession();
...
session.save(object);
..
session.update(object);
....

for example..

try
{
session.save(object);
}
catch (HibernateException e)
{
System.err.println("++++++++++++++Hibernate Exception" + e.getMessage());
throw new RuntimeException(e);
}

but when an exception is thrown... it finish in zk alert window or output console, and complety ignores my try-catch... is there a configuration to avoid this issue?

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2007-01-02 02:34:58 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4080228

By: henrichen

The original exception might be wrapped by ZK's UiException I guess. Can you do catch Exception and see if I am guessing right?

try {
...
} catch(Exception e) {
System.err.println("+++++++++++ exception="+e); throw e; }

/henri


link publish delete flag offensive edit

answered 2007-01-22 21:33:06 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4116759

By: cmaniac

well.. let me tell you something

1. I still, with the problem.. I Mean.. at last I found a way to catch hibernate exceptons... but.. not all, let me explain you.. I found that if a try to catch the exception in this way:

public void confirmarTransaccion() throws Exception {
Session _session
= HibernateUtil.getSessionFactory().getCurrentSession();
_session.flush();
}
and...
try {
//...
super.confirmarTransaccion();
}
catch (Exception e) {
//---cualquier error ocurrido por hibernate
super.lanzarExcepcion(new ExcepcionDatos("Error: Algo ocurrio con hibernate",e));
}

I can view this... in my view:

com.casewaresa.framework.excepciones.ExcepcionNegocio: Error: Algo ocurrio con hibernate
at com.casewaresa.framework.action.PruebaExcepcionAction.mostrar3(PruebaExcepci
onAction.java:71)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at bsh.Reflect.invokeMethod(Unknown Source)
at bsh.Reflect.invokeObjectMethod(Unknown Source)
at bsh.Name.invokeMethod(Unknown Source)
at bsh.BSHMethodInvocation.eval(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.Interpreter.eval(Unknown Source)
at bsh.Interpreter.eval(Unknown Source)
at org.zkoss.zk.ui.impl.bsh.BshInterpreter.interpret(BshInterpreter.java:108)
at org.zkoss.zk.ui.impl.PageImpl.interpret(PageImpl.java:565)
at org.zkoss.zk.ui.impl.EventProcessingThread.process1(EventProcessingThread.ja
va:474)
at org.zkoss.zk.ui.impl.EventProcessingThread.process0(EventProcessingThread.ja
va:453)
at org.zkoss.zk.ui.impl.EventProcessingThread.run(EventProcessingThread.java:36
0)
Caused by: org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java
:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:249)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(Abst
ractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventL
istener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper
.invoke(ThreadLocalSessionContext.java:301)
at $Proxy1.flush(Unknown Source)
at com.casewaresa.framework.frameworkStandard.action.ActionStandard.confirmarTr
ansaccion(ActionStandard.java:306)
at com.casewaresa.framework.action.PruebaExcepcionAction.mostrar3(PruebaExcepci
onAction.java:67)
... 17 more
Caused by: java.sql.BatchUpdateException: ORA-00904: invalid column name

at oracle.jdbc.dbaccess.DBError.throwBatchUpdateException(DBError.java:459)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatem
ent.java:4133)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242)
... 30 more


but.... and here is the problem.. in the console still shows this:
ERROR-->(AbstractFlushingEventListener.java:linea 301)- Could not
ERROR-->synchronize
database state with session
org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java
:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:249)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(Abst
ractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventL
istener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper
.invoke(ThreadLocalSessionContext.java:301)
at $Proxy2.flush(Unknown Source)
at com.casewaresa.framework.frameworkStandard.action.ActionStandard.confirmarTr
ansaccion(ActionStandard.java:306)
at com.casewaresa.framework.action.PruebaExcepcionAction.mostrar3(PruebaExcepci
onAction.java:67)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at bsh.Reflect.invokeMethod(Unknown Source)
at bsh.Reflect.invokeObjectMethod(Unknown Source)
at bsh.Name.invokeMethod(Unknown Source)
at bsh.BSHMethodInvocation.eval(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.Interpreter.eval(Unknown Source)
at bsh.Interpreter.eval(Unknown Source)
at org.zkoss.zk.ui.impl.bsh.BshInterpreter.interpret(BshInterpreter.java:108)
at org.zkoss.zk.ui.impl.PageImpl.interpret(PageImpl.java:565)
at org.zkoss.zk.ui.impl.EventProcessingThread.process1(EventProcessingThread.ja
va:474)
at org.zkoss.zk.ui.impl.EventProcessingThread.process0(EventProcessingThread.ja
va:453)
at org.zkoss.zk.ui.impl.EventProcessingThread.run(EventProcessingThread.java:36
0)
Caused by: java.sql.BatchUpdateException: ORA-00904: invalid column name

at oracle.jdbc.dbaccess.DBError.throwBatchUpdateException(DBError.java:459)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatem
ent.java:4133)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242)
... 30 more
INFO-->(ActionStandard.java:linea 344)- ejecutando [ mostrarExcepcion ]...


and here is the cuestion... then how I must catch the exception.. so it does'n show in the console but in my view, completely (I must show de stacktrace in a window...)

link publish delete flag offensive edit

answered 2007-01-23 15:27:16 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4118146

By: ksg9-seb

To catch the exceptions is not a good way, you should avoid the exceptions :) Can u show more code and your hibernate configuration?

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2006-12-29 14:12:14 +0800

Seen: 469 times

Last updated: Jan 23 '07

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More