Hi All,
I am new to hibernate. We have a scenario like this.
In my application we are not using Hibernate. But there is a scenario where for the new feature we are adding hibernate.
In CMT we are calling a method which will do some db opertions using hibernate. But the results are not persisting in the db. it is throwing exceptions.
skelton:
CustomService(CMT) {
PartyRole (CMT) -> THIS IS NORMAL JXP (JDBC CALL)
Hibernate -> THIS IS A HIBERNATE CALL
}
sample code here:
public void find(){
/* some code here */
Retval = commonObjectBOB.create(username, authentication, theBO); -> db call..
String partyRoleID=retval.getId();
testPartyHib(partyRoleID); -> hibernate call..
}
public void testPartyHib(String id) throws Exception {
Session session = null;
try{
Configuration cfg = new Configuration();
SessionFactory sessionFactory=(SessionFactory) cfg.configure(CONFIG_FILE_LOCATION).buildSessionFactory();
session = sessionFactory.openSession();
// session.beginTransaction();
TestPartyHib testPartyHib = new TestPartyHib();
testPartyHib.setId(1L);
testPartyHib.setPartyRoleId(id);
session.save(testPartyHib);
session.flush();
//session.getTransaction().commit();
}
catch (SQLGrammarException ex) {
throw (SQLGrammarException) ex;
} finally{
session.close();
}
}
I am getting below error:
[6/14/10 14:52:17:962 EDT] 00000013 SystemOut O Hibernate: insert into TESTPARTYHIB (PARTYROLEID, id) values (?, ?)
[6/14/10 14:53:18:229 EDT] 00000013 SystemOut O 2010-06-14 14:53:18,219 [ORB.thread.pool : 2] ERROR org.hibernate.util.JDBCExceptionReporter - ORA-02049: timeout: distributed transaction waiting for lock
[6/14/10 14:53:18:229 EDT] 00000013 SystemOut O 2010-06-14 14:53:18,229 [ORB.thread.pool : 2] ERROR org.hibernate.util.JDBCExceptionReporter - ORA-02049: timeout: distributed transaction waiting for lock
[6/14/10 14:53:18:349 EDT] 00000013 SystemOut O 2010-06-14 14:53:18,259 [ORB.thread.pool : 2] ERROR org.hibernate.event.def.AbstractFlushingEventListener - Could not 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:253)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:237)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at com.chordiant.pmf.service.PartyRoleService.testPartyHib(PartyRoleService.java:298)
at com.chordiant.pmf.service.PartyRoleService.create(PartyRoleService.java:257)
at com.chordiant.pmf.service.PartyRoleService.processRequest(PartyRoleService.java:1809)
at com.chordiant.service.MasterStatelessServiceBean.processRequest(MasterStatelessServiceBean.java:527)
at com.chordiant.service.GatewayHandler.processRequest(GatewayHandler.java:266)
at com.chordiant.service.ejb.EJBGatewayServiceBean.processRequestObject(EJBGatewayServiceBean.java:172)
at com.chordiant.service.ejb.EJSRemoteStatelessEJBGatewayServiceCMT_47cd5805.processRequestObject(EJSRemoteStatelessEJBGatewayServiceCMT_47cd5805.java:28)
at com.chordiant.service.ejb._EJSRemoteStatelessEJBGatewayServiceCMT_47cd5805_Tie.processRequestObject(_EJSRemoteStatelessEJBGatewayServiceCMT_47cd5805_Tie.java:197)
at com.chordiant.service.ejb._EJSRemoteStatelessEJBGatewayServiceCMT_47cd5805_Tie._invoke(_EJSRemoteStatelessEJBGatewayServiceCMT_47cd5805_Tie.java:106)
at com.ibm.CORBA.iiop.ServerDelegate.dispatchInvokeHandler(ServerDelegate.java:613)
at com.ibm.CORBA.iiop.ServerDelegate.dispatch(ServerDelegate.java:466)
at com.ibm.rmi.iiop.ORB.process(ORB.java:503)
at com.ibm.CORBA.iiop.ORB.process(ORB.java:1552)
at com.ibm.rmi.iiop.Connection.respondTo(Connection.java:2673)
at com.ibm.rmi.iiop.Connection.doWork(Connection.java:2551)
at com.ibm.rmi.iiop.WorkUnitImpl.doWork(WorkUnitImpl.java:62)
at com.ibm.ejs.oa.pool.PooledThread.run(ThreadPool.java:118)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1469)
Caused by:
java.sql.BatchUpdateException: ORA-02049: timeout: distributed transaction waiting for lock
at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:343)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10656)
at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.pmiExecuteBatch(WSJdbcPreparedStatement.java:808)
at com.ibm.ws.rsadapter.jdbc.WSJdbcStatement.executeBatch(WSJdbcStatement.java:612)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
... 23 more
[6/14/10 14:53:18:349 EDT] 00000013 SystemOut O Exception visu java.sql.SQLException: ORA-02049: timeout: distributed transaction waiting for lock
[6/14/10 14:53:18:409 EDT] 00000013 SystemOut O <Mon Jun 14 14:53:18 EDT 2010> <1276541598409> <ERROR> <Thd=ORB.thread.pool : 2> <com.chordiant.pmf.service.PartyRoleService.create()> <Exception occured <org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update> >
[6/14/10 14:53:18:409 EDT] 00000013 SystemOut O <Mon Jun 14 14:53:18 EDT 2010> <1276541598409> <ERROR> <Thd=ORB.thread.pool : 2> <com.chordiant.pmf.service.PartyRoleService.processRequest()> <Exception occured <org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update> >
[6/14/10 14:53:18:419 EDT] 00000013 ExceptionUtil E CNTR0020E: EJB threw an unexpected (non-declared) exception during invocation of method "processRequestObject" on bean "BeanId(ChordiantEAR#ChordiantEJB.jar#EJBGatewayServiceCMT, null)". Exception data: 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:253)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:237)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at com.chordiant.pmf.service.PartyRoleService.testPartyHib(PartyRoleService.java:298)
at com.chordiant.pmf.service.PartyRoleService.create(PartyRoleService.java:257)
at com.chordiant.pmf.service.PartyRoleService.processRequest(PartyRoleService.java:1809)
at com.chordiant.service.MasterStatelessServiceBean.processRequest(MasterStatelessServiceBean.java:527)
at com.chordiant.service.GatewayHandler.processRequest(GatewayHandler.java:266)
at com.chordiant.service.ejb.EJBGatewayServiceBean.processRequestObject(EJBGatewayServiceBean.java:172)
at com.chordiant.service.ejb.EJSRemoteStatelessEJBGatewayServiceCMT_47cd5805.processRequestObject(EJSRemoteStatelessEJBGatewayServiceCMT_47cd5805.java:28)
at com.chordiant.service.ejb._EJSRemoteStatelessEJBGatewayServiceCMT_47cd5805_Tie.processRequestObject(_EJSRemoteStatelessEJBGatewayServiceCMT_47cd5805_Tie.java:197)
at com.chordiant.service.ejb._EJSRemoteStatelessEJBGatewayServiceCMT_47cd5805_Tie._invoke(_EJSRemoteStatelessEJBGatewayServiceCMT_47cd5805_Tie.java:106)
at com.ibm.CORBA.iiop.ServerDelegate.dispatchInvokeHandler(ServerDelegate.java:613)
at com.ibm.CORBA.iiop.ServerDelegate.dispatch(ServerDelegate.java:466)
at com.ibm.rmi.iiop.ORB.process(ORB.java:503)
at com.ibm.CORBA.iiop.ORB.process(ORB.java:1552)
at com.ibm.rmi.iiop.Connection.respondTo(Connection.java:2673)
at com.ibm.rmi.iiop.Connection.doWork(Connection.java:2551)
at com.ibm.rmi.iiop.WorkUnitImpl.doWork(WorkUnitImpl.java:62)
at com.ibm.ejs.oa.pool.PooledThread.run(ThreadPool.java:118)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1469)
Caused by: java.sql.BatchUpdateException: ORA-02049: timeout: distributed transaction waiting for lock
at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:343)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10656)
at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.pmiExecuteBatch(WSJdbcPreparedStatement.java:808)
at com.ibm.ws.rsadapter.jdbc.WSJdbcStatement.executeBatch(WSJdbcStatement.java:612)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
... 23 more
---- Begin backtrace for Nested Throwables
java.sql.SQLException: ORA-02049: timeout: distributed transaction waiting for lock
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:213)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:952)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10580)
at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.pmiExecuteBatch(WSJdbcPreparedStatement.java:808)
at com.ibm.ws.rsadapter.jdbc.WSJdbcStatement.executeBatch(WSJdbcStatement.java:612)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:237)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at com.chordiant.pmf.service.PartyRoleService.testPartyHib(PartyRoleService.java:298)
at com.chordiant.pmf.service.PartyRoleService.create(PartyRoleService.java:257)
at com.chordiant.pmf.service.PartyRoleService.processRequest(PartyRoleService.java:1809)
at com.chordiant.service.MasterStatelessServiceBean.processRequest(MasterStatelessServiceBean.java:527)
at com.chordiant.service.GatewayHandler.processRequest(GatewayHandler.java:266)
at com.chordiant.service.ejb.EJBGatewayServiceBean.processRequestObject(EJBGatewayServiceBean.java:172)
at com.chordiant.service.ejb.EJSRemoteStatelessEJBGatewayServiceCMT_47cd5805.processRequestObject(EJSRemoteStatelessEJBGatewayServiceCMT_47cd5805.java:28)
at com.chordiant.service.ejb._EJSRemoteStatelessEJBGatewayServiceCMT_47cd5805_Tie.processRequestObject(_EJSRemoteStatelessEJBGatewayServiceCMT_47cd5805_Tie.java:197)
at com.chordiant.service.ejb._EJSRemoteStatelessEJBGatewayServiceCMT_47cd5805_Tie._invoke(_EJSRemoteStatelessEJBGatewayServiceCMT_47cd5805_Tie.java:106)
at com.ibm.CORBA.iiop.ServerDelegate.dispatchInvokeHandler(ServerDelegate.java:613)
at com.ibm.CORBA.iiop.ServerDelegate.dispatch(ServerDelegate.java:466)
at com.ibm.rmi.iiop.ORB.process(ORB.java:503)
at com.ibm.CORBA.iiop.ORB.process(ORB.java:1552)
at com.ibm.rmi.iiop.Connection.respondTo(Connection.java:2673)
at com.ibm.rmi.iiop.Connection.doWork(Connection.java:2551)
at com.ibm.rmi.iiop.WorkUnitImpl.doWork(WorkUnitImpl.java:62)
at com.ibm.ejs.oa.pool.PooledThread.run(ThreadPool.java:118)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1469)
Queries:
1. Can I use hibernate in CMT? If Yes, any configuration required?
2. Is it any dependency on ejb transaction attribute? I have tried with required, requiresNew. but did not work.