Announcement Announcement Module
Collapse
No announcement yet.
Handling Exception thrown at the time of trnasaction commit? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Handling Exception thrown at the time of trnasaction commit?

    Hi All ,
    I am using Spring's declarative transaction demarcation.

    The configuration is like this :

    <bean id="INVOICE_MANAGER"
    class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
    <property name="transactionManager"><ref local="TransactionManager"/></property>
    <property name="target"><ref local="INVOICE_MANAGER_TARGET"/></property>
    <property name="transactionAttributes">
    <props>
    <prop key="parserCSV">PROPAGATION_REQUIRED,-qc.qbid.invoice.model.exception.InvoiceException, -org.springframework.dao.DataAccess </props>
    </property>
    </bean>


    Transaction is working fine . But i am facing one strange problem. The problem is like this :
    In this method , some records are inserted into the database. Now if it tries to insert existing record ( some record violating unique key constrint) it is throwing DataIntegrityViolationException . But i have handled it in this method. But still somehow it is not going into that catch block and as exception is not handled application is throwing white page.

    The code used for insertion of rec is


    try {
    if (!fatalListFlag) {
    this.saveInvoiceBillingDevices(objectList, invObj,
    objectListSize, listSize);
    } catch (DataAccessException dae) {
    logger.error(dae.fillInStackTrace());
    throw new InvoiceException(dae.getMessage());
    }


    Stack trace of the same is :
    29:44,609 DEBUG ApplicationFactory:53 - New ApplicationFactory instance created
    11:33:40,343 ERROR JDBCExceptionReporter:58 - ORA-00001: unique constraint (TESTDATA19.INVOICE_BILL_DEVICE_DATE_UK) violated

    11:33:40,343 ERROR JDBCExceptionReporter:58 - ORA-00001: unique constraint (TESTDATA19.INVOICE_BILL_DEVICE_DATE_UK) violated

    11:33:40,406 ERROR AbstractFlushingEventListener:277 - Could not synchronize database state with session
    org.hibernate.exception.ConstraintViolationExcepti on: Could not execute JDBC batch update
    at org.hibernate.exception.ErrorCodeConverter.convert (ErrorCodeConverter.java:74)
    at org.hibernate.exception.JDBCExceptionHelper.conver t(JDBCExceptionHelper.java:43)
    at org.hibernate.jdbc.AbstractBatcher.executeBatch(Ab stractBatcher.java:161)
    at org.hibernate.jdbc.AbstractBatcher.prepareStatemen t(AbstractBatcher.java:71)
    at org.hibernate.jdbc.AbstractBatcher.prepareStatemen t(AbstractBatcher.java:66)
    at org.hibernate.jdbc.AbstractBatcher.prepareBatchSta tement(AbstractBatcher.java:130)
    at org.hibernate.persister.entity.BasicEntityPersiste r.insert(BasicEntityPersister.java:1809)
    at org.hibernate.persister.entity.BasicEntityPersiste r.insert(BasicEntityPersister.java:2171)
    at org.hibernate.action.EntityInsertAction.execute(En tityInsertAction.java:46)
    at org.hibernate.engine.ActionQueue.execute(ActionQue ue.java:239)
    at org.hibernate.engine.ActionQueue.executeActions(Ac tionQueue.java:223)
    at org.hibernate.engine.ActionQueue.executeActions(Ac tionQueue.java:136)
    at org.hibernate.event.def.AbstractFlushingEventListe ner.performExecutions(AbstractFlushingEventListene r.java:274)
    at org.hibernate.event.def.DefaultFlushEventListener. onFlush(DefaultFlushEventListener.java:27)
    at org.hibernate.impl.SessionImpl.flush(SessionImpl.j ava:669)
    at org.hibernate.impl.SessionImpl.managedFlush(Sessio nImpl.java:293)
    at org.hibernate.transaction.JDBCTransaction.commit(J DBCTransaction.java:86)
    at org.springframework.orm.hibernate3.HibernateTransa ctionManager.doCommit(HibernateTransactionManager. java:488)
    at org.springframework.transaction.support.AbstractPl atformTransactionManager.commit(AbstractPlatformTr ansactionManager.java:435)
    at org.springframework.transaction.interceptor.Transa ctionAspectSupport.doCommitTransactionAfterReturni ng(TransactionAspectSupport.java:258)
    at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:67)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :144)
    at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:174)
    at $Proxy4.parserCSV(Unknown Source)
    at qc.qbid.invoice.view.bean.InvoiceDetailsMBean.onCl ickImport(Unknown Source)
    at qc.qbid.invoice.view.bean.InvoiceDetailsMBean.uplo ad(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at org.apache.myfaces.el.MethodBindingImpl.invoke(Met hodBindingImpl.java:138)
    at org.apache.myfaces.application.ActionListenerImpl. processAction(ActionListenerImpl.java:62)
    at javax.faces.component.UICommand.broadcast(UIComman d.java:106)
    at javax.faces.component.UIViewRoot._broadcastForPhas e(UIViewRoot.java:110)
    at javax.faces.component.UIViewRoot.processApplicatio n(UIViewRoot.java:184)
    at org.apache.myfaces.lifecycle.LifecycleImpl.invokeA pplication(LifecycleImpl.java:259)
    at org.apache.myfaces.lifecycle.LifecycleImpl.execute (LifecycleImpl.java:90)
    at javax.faces.webapp.FacesServlet.service(FacesServl et.java:109)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:237)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:157)
    at qc.commons.auth.ChannelsAuthenticationFilter.doFil ter(Unknown Source)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:186)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:157)
    at org.apache.myfaces.component.html.util.ExtensionsF ilter.doFilter(ExtensionsFilter.java:119)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:186)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:157)
    at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:214)
    at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:104)
    at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:520)
    at org.apache.catalina.core.StandardContextValve.invo keInternal(StandardContextValve.java:198)
    at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:152)
    at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:104)
    at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:520)
    at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:137)
    at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:104)
    at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:118)
    at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:102)
    at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:520)
    at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:109)
    at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:104)
    at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:520)
    at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:929)
    at org.apache.coyote.tomcat5.CoyoteAdapter.service(Co yoteAdapter.java:160)
    at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:799)
    at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.processConnection(Http11Protocol.jav a:705)
    at org.apache.tomcat.util.net.TcpWorkerThread.runIt(P oolTcpEndpoint.java:577)
    at org.apache.tomcat.util.threads.ThreadPool$ControlR unnable.run(ThreadPool.java:683)
    at java.lang.Thread.run(Thread.java:536)
    Caused by: java.sql.BatchUpdateException: ORA-00001: unique constraint (TESTDATA19.INVOICE_BILL_DEVICE_DATE_UK) violated

    at oracle.jdbc.dbaccess.DBError.throwBatchUpdateExcep tion(DBError.java:459)
    at oracle.jdbc.driver.OraclePreparedStatement.execute Batch(OraclePreparedStatement.java:3907)
    at org.apache.commons.dbcp.DelegatingStatement.execut eBatch(DelegatingStatement.java:294)
    at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch( BatchingBatcher.java:57)
    at org.hibernate.jdbc.AbstractBatcher.executeBatch(Ab stractBatcher.java:154)
    ... 65 more
    11:33:40,421 ERROR MethodBindingImpl:162 - Exception while invoking expression #{InvoiceDetailsMBean.upload}
    org.springframework.dao.DataIntegrityViolationExce ption: Hibernate operation: Could not execute JDBC batch update; ORA-00001: unique constraint (TESTDATA19.INVOICE_BILL_DEVICE_DATE_UK) violated
    ; nested exception is java.sql.BatchUpdateException: ORA-00001: unique constraint (TESTDATA19.INVOICE_BILL_DEVICE_DATE_UK) violated

    java.sql.BatchUpdateException: ORA-00001: unique constraint (TESTDATA19.INVOICE_BILL_DEVICE_DATE_UK) violated

    at oracle.jdbc.dbaccess.DBError.throwBatchUpdateExcep tion(DBError.java:459)
    at oracle.jdbc.driver.OraclePreparedStatement.execute Batch(OraclePreparedStatement.java:3907)
    at org.apache.commons.dbcp.DelegatingStatement.execut eBatch(DelegatingStatement.java:294)
    at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch( BatchingBatcher.java:57)
    at org.hibernate.jdbc.AbstractBatcher.executeBatch(Ab stractBatcher.java:154)
    at org.hibernate.jdbc.AbstractBatcher.prepareStatemen t(AbstractBatcher.java:71)
    at org.hibernate.jdbc.AbstractBatcher.prepareStatemen t(AbstractBatcher.java:66)
    at org.hibernate.jdbc.AbstractBatcher.prepareBatchSta tement(AbstractBatcher.java:130)
    at org.hibernate.persister.entity.BasicEntityPersiste r.insert(BasicEntityPersister.java:1809)
    at org.hibernate.persister.entity.BasicEntityPersiste r.insert(BasicEntityPersister.java:2171)
    at org.hibernate.action.EntityInsertAction.execute(En tityInsertAction.java:46)
    at org.hibernate.engine.ActionQueue.execute(ActionQue ue.java:239)
    at org.hibernate.engine.ActionQueue.executeActions(Ac tionQueue.java:223)
    at org.hibernate.engine.ActionQueue.executeActions(Ac tionQueue.java:136)
    at org.hibernate.event.def.AbstractFlushingEventListe ner.performExecutions(AbstractFlushingEventListene r.java:274)
    at org.hibernate.event.def.DefaultFlushEventListener. onFlush(DefaultFlushEventListener.java:27)
    at org.hibernate.impl.SessionImpl.flush(SessionImpl.j ava:669)
    at org.hibernate.impl.SessionImpl.managedFlush(Sessio nImpl.java:293)
    at org.hibernate.transaction.JDBCTransaction.commit(J DBCTransaction.java:86)
    at org.springframework.orm.hibernate3.HibernateTransa ctionManager.doCommit(HibernateTransactionManager. java:488)
    at org.springframework.transaction.support.AbstractPl atformTransactionManager.commit(AbstractPlatformTr ansactionManager.java:435)
    at org.springframework.transaction.interceptor.Transa ctionAspectSupport.doCommitTransactionAfterReturni ng(TransactionAspectSupport.java:258)
    at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:67)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :144)
    at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:174)
    at $Proxy4.parserCSV(Unknown Source)
    at qc.qbid.invoice.view.bean.InvoiceDetailsMBean.onCl ickImport(Unknown Source)
    at qc.qbid.invoice.view.bean.InvoiceDetailsMBean.uplo ad(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at org.apache.myfaces.el.MethodBindingImpl.invoke(Met hodBindingImpl.java:138)
    at org.apache.myfaces.application.ActionListenerImpl. processAction(ActionListenerImpl.java:62)
    at javax.faces.component.UICommand.broadcast(UIComman d.java:106)
    at javax.faces.component.UIViewRoot._broadcastForPhas e(UIViewRoot.java:110)
    at javax.faces.component.UIViewRoot.processApplicatio n(UIViewRoot.java:184)
    at org.apache.myfaces.lifecycle.LifecycleImpl.invokeA pplication(LifecycleImpl.java:259)
    at org.apache.myfaces.lifecycle.LifecycleImpl.execute (LifecycleImpl.java:90)
    at javax.faces.webapp.FacesServlet.service(FacesServl et.java:109)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:237)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:157)
    at qc.commons.auth.ChannelsAuthenticationFilter.doFil ter(Unknown Source)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:186)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:157)
    at org.apache.myfaces.component.html.util.ExtensionsF ilter.doFilter(ExtensionsFilter.java:119)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:186)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:157)
    at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:214)
    at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:104)
    at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:520)
    at org.apache.catalina.core.StandardContextValve.invo keInternal(StandardContextValve.java:198)
    at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:152)
    at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:104)
    at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:520)
    at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:137)
    at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:104)
    at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:118)
    at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:102)
    at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:520)
    at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:109)
    at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:104)
    at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:520)
    at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:929)
    at org.apache.coyote.tomcat5.CoyoteAdapter.service(Co yoteAdapter.java:160)
    at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:799)
    at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.processConnection(Http11Protocol.jav a:705)
    at org.apache.tomcat.util.net.TcpWorkerThread.runIt(P oolTcpEndpoint.java:577)
    at org.apache.tomcat.util.threads.ThreadPool$ControlR unnable.run(ThreadPool.java:683)
    at java.lang.Thread.run(Thread.java:536)
    11:33:40,437 ERROR ActionListenerImpl:73 - Error calling action method of component with id body:frmInvoiceDetails:_id57
    javax.faces.el.EvaluationException: Expression: #{InvoiceDetailsMBean.upload}
    at org.apache.myfaces.el.MethodBindingImpl.invoke(Met hodBindingImpl.java:164)
    at org.apache.myfaces.application.ActionListenerImpl. processAction(ActionListenerImpl.java:62)
    at javax.faces.component.UICommand.broadcast(UIComman d.java:106)
    at javax.faces.component.UIViewRoot._broadcastForPhas e(UIViewRoot.java:110)
    at javax.faces.component.UIViewRoot.processApplicatio n(UIViewRoot.java:184)
    at org.apache.myfaces.lifecycle.LifecycleImpl.invokeA pplication(LifecycleImpl.java:259)
    at org.apache.myfaces.lifecycle.LifecycleImpl.execute (LifecycleImpl.java:90)
    at javax.faces.webapp.FacesServlet.service(FacesServl et.java:109)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:237)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:157)
    at qc.commons.auth.ChannelsAuthenticationFilter.doFil ter(Unknown Source)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:186)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:157)
    at org.apache.myfaces.component.html.util.ExtensionsF ilter.doFilter(ExtensionsFilter.java:119)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:186)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:157)
    at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:214)
    at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:104)
    at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:520)
    at org.apache.catalina.core.StandardContextValve.invo keInternal(StandardContextValve.java:198)
    at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:152)
    at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:104)
    at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:520)
    at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:137)
    at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:104)
    at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:118)
    at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:102)
    at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:520)
    at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:109)
    at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:104)
    at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:520)
    at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:929)
    at org.apache.coyote.tomcat5.CoyoteAdapter.service(Co yoteAdapter.java:160)
    at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:799)
    at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.processConnection(Http11Protocol.jav a:705)
    at org.apache.tomcat.util.net.TcpWorkerThread.runIt(P oolTcpEndpoint.java:577)
    at org.apache.tomcat.util.threads.ThreadPool$ControlR unnable.run(ThreadPool.java:683)
    at java.lang.Thread.run(Thread.java:536)
    Caused by: org.springframework.dao.DataIntegrityViolationExce ption: Hibernate operation: Could not execute JDBC batch update; ORA-00001: unique constraint (TESTDATA19.INVOICE_BILL_DEVICE_DATE_UK) violated
    ; nested exception is java.sql.BatchUpdateException: ORA-00001: unique constraint (TESTDATA19.INVOICE_BILL_DEVICE_DATE_UK) violated

    at org.springframework.jdbc.support.SQLErrorCodeSQLEx ceptionTranslator.translate(SQLErrorCodeSQLExcepti onTranslator.java:235)
    at org.springframework.orm.hibernate3.HibernateTransa ctionManager.convertJdbcAccessException(HibernateT ransactionManager.java:598)
    at org.springframework.orm.hibernate3.HibernateTransa ctionManager.convertHibernateAccessException(Hiber nateTransactionManager.java:584)
    at org.springframework.orm.hibernate3.HibernateTransa ctionManager.doCommit(HibernateTransactionManager. java:496)
    at org.springframework.transaction.support.AbstractPl atformTransactionManager.commit(AbstractPlatformTr ansactionManager.java:435)
    at org.springframework.transaction.interceptor.Transa ctionAspectSupport.doCommitTransactionAfterReturni ng(TransactionAspectSupport.java:258)
    at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:67)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :144)
    at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:174)
    at $Proxy4.parserCSV(Unknown Source)
    at qc.qbid.invoice.view.bean.InvoiceDetailsMBean.onCl ickImport(Unknown Source)
    at qc.qbid.invoice.view.bean.InvoiceDetailsMBean.uplo ad(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at org.apache.myfaces.el.MethodBindingImpl.invoke(Met hodBindingImpl.java:138)
    ... 37 more
    Caused by: java.sql.BatchUpdateException: ORA-00001: unique constraint (TESTDATA19.INVOICE_BILL_DEVICE_DATE_UK) violated

    at oracle.jdbc.dbaccess.DBError.throwBatchUpdateExcep tion(DBError.java:459)
    at oracle.jdbc.driver.OraclePreparedStatement.execute Batch(OraclePreparedStatement.java:3907)
    at org.apache.commons.dbcp.DelegatingStatement.execut eBatch(DelegatingStatement.java:294)
    at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch( BatchingBatcher.java:57)
    at org.hibernate.jdbc.AbstractBatcher.executeBatch(Ab stractBatcher.java:154)
    at org.hibernate.jdbc.AbstractBatcher.prepareStatemen t(AbstractBatcher.java:71)
    at org.hibernate.jdbc.AbstractBatcher.prepareStatemen t(AbstractBatcher.java:66)
    at org.hibernate.jdbc.AbstractBatcher.prepareBatchSta tement(AbstractBatcher.java:130)
    at org.hibernate.persister.entity.BasicEntityPersiste r.insert(BasicEntityPersister.java:1809)
    at org.hibernate.persister.entity.BasicEntityPersiste r.insert(BasicEntityPersister.java:2171)
    at org.hibernate.action.EntityInsertAction.execute(En tityInsertAction.java:46)
    at org.hibernate.engine.ActionQueue.execute(ActionQue ue.java:239)
    at org.hibernate.engine.ActionQueue.executeActions(Ac tionQueue.java:223)
    at org.hibernate.engine.ActionQueue.executeActions(Ac tionQueue.java:136)
    at org.hibernate.event.def.AbstractFlushingEventListe ner.performExecutions(AbstractFlushingEventListene r.java:274)
    at org.hibernate.event.def.DefaultFlushEventListener. onFlush(DefaultFlushEventListener.java:27)
    at org.hibernate.impl.SessionImpl.flush(SessionImpl.j ava:669)
    at org.hibernate.impl.SessionImpl.managedFlush(Sessio nImpl.java:293)
    at org.hibernate.transaction.JDBCTransaction.commit(J DBCTransaction.java:86)
    at org.springframework.orm.hibernate3.HibernateTransa ctionManager.doCommit(HibernateTransactionManager. java:488)
    ... 50 more


    I observed this trace carefully . The exception is thrown when transaction is committed. So can anybody tell me how can i handle this exception in this method only ? I mean i need the record information for which insertion is failed .

    Thanks in advance

  • #2
    In this method , some records are inserted into the database. Now if it tries to insert existing record ( some record violating unique key constrint) it is throwing DataIntegrityViolationException . But i have handled it in this method.
    You need to call flush to guarantee the insert occurs within this method.

    Comment

    Working...
    X