on 06-04-2005 8:42 PM
I am getting the following stacktrace (see below) while modifying CMR relationships. The cause of the exception is that duplicate rows are being inserted into the DB during the flush that occurs upon findByPrimaryKey(). This is likely triggered due to the fact that we are modifying both sides of the relationship during the same transaction. This should be supported though, right?
I also configured the finder methods not to flush using the <switch-off-storing/> tag in persistent.xml. This causes other problems for us though.
Any help would be greatly appreciated.
Cheers,
Chad
com.sap.engine.services.ejb.exceptions.BaseEJBException: SQLException when the data is flushed.
at com.sap.engine.services.ejb.entity.pm.PersistentM2M.ejbFlush(PersistentM2M.java:141)
at com.sap.engine.services.ejb.entity.pm.TransactionContext.flushAll(TransactionContext.java:429)
at com.sap.engine.services.ejb.entity.pm.TransactionContext.flushAllBeforeFindMethod(TransactionContext.java:403)
at com.sap.engine.services.ejb.entity.pm.PersistenceManager.getConnectionForFindMethod(PersistenceManager.java:346)
at turtle.runtime.generated.Local_Domain2mu7nv_weblogadlnph.structure.EBcommentBean0PM.ejbFindByPrimaryKey(EBcommentBean0PM.java:378)
at turtle.runtime.generated.Local_Domain2mu7nv_weblogadlnph.structure.LocalEBcommentHomeImpl0.findByPrimaryKey(LocalEBcommentHomeImpl0.java:816)
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:324)
at turtle.common.util.ReflectionUtils.invoke(ReflectionUtils.java:647)
at turtle.server.runtime.util.RuntimeRemoteUtils.getLocalObject(RuntimeRemoteUtils.java:414)
at turtle.server.runtime.util.RuntimeRemoteUtils.getLocalObject(RuntimeRemoteUtils.java:401)
at turtle.server.runtime.EBSharedBase.updateStorage(EBSharedBase.java:106)
at turtle.runtime.generated.Local_Domain2mu7nv_weblogadlnph.structure.EBpostBean.updateRelationships(EBpostBean.java:302)
at turtle.runtime.generated.Local_Domain2mu7nv_weblogadlnph.structure.LocalEBpostLocalObjectImpl0.updateRelationships(LocalEBpostLocalObjectImpl0.java:1341)
at turtle.server.runtime.util.RuntimeRemoteUtils.updateRelationships(RuntimeRemoteUtils.java:1047)
at turtle.server.runtime.data.GlobalCollection.add(GlobalCollection.java:124)
at turtle.server.runtime.data.GlobalCollectionBase.add(GlobalCollectionBase.java:303)
at turtle.server.runtime.util.RuntimeRemoteUtils.add(RuntimeRemoteUtils.java:67)
at turtle.server.runtime.util.RuntimeRemoteUtils.add(RuntimeRemoteUtils.java:82)
at turtle.runtime.generated.Local_Domain2mu7nv_weblogadlnph.process.LBinitializeweblogsettingsBean.init_PostAndComment_stepMethod_11(LBinitializeweblogsettingsBean.java:8643)
at turtle.runtime.generated.Local_Domain2mu7nv_weblogadlnph.process.LBinitializeweblogsettingsBean.execute(LBinitializeweblogsettingsBean.java:214)
at turtle.runtime.generated.Local_Domain2mu7nv_weblogadlnph.process.LBinitializeweblogsettingsBean.execute(LBinitializeweblogsettingsBean.java:318)
at turtle.server.runtime.process.DynamicProcessBean.exec_and_return(DynamicProcessBean.java:593)
at turtle.server.runtime.process.DynamicProcessBean.inlineExecute(DynamicProcessBean.java:497)
at turtle.runtime.generated.Local_Domain2mu7nv_weblogadlnph.process.LBweblogBean.default_stepMethod_3(LBweblogBean.java:2536)
at turtle.runtime.generated.Local_Domain2mu7nv_weblogadlnph.process.LBweblogBean.execute(LBweblogBean.java:181)
at turtle.runtime.generated.Local_Domain2mu7nv_weblogadlnph.process.LBweblogBean.executeComponentUI(LBweblogBean.java:387)
at turtle.runtime.generated.Local_Domain2mu7nv_weblogadlnph.process.SBweblogObjectImpl0.executeComponentUI(SBweblogObjectImpl0.java:710)
at turtle.runtime.generated.Local_Domain2mu7nv_weblogadlnph.process.SBweblog_Stub.executeComponentUI(SBweblog_Stub.java:735)
at turtle.web.process.ProcessEntryPointServlet.serviceUIProcess(ProcessEntryPointServlet.java:89)
at turtle.web.process.ProcessEntryPointServlet.serviceUIProcess(ProcessEntryPointServlet.java:48)
at turtle.web.process.ProcessEntryPointServlet.service(ProcessEntryPointServlet.java:160)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:391)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:265)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:345)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:323)
at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:865)
at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:240)
at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:37)
at com.sap.engine.core.cluster.impl6.session.UnorderedChannel$MessageRunner.run(UnorderedChannel.java:71)
at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
at java.security.AccessController.doPrivileged(Native Method)
at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:94)
at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:162)
Caused by: java.sql.SQLException: [SkywaySoftware][SQLServer JDBC Driver][SQLServer]Cannot insert duplicate key row in object 's13q8n3Comments_Po' with unique index 's13q8n3Comments_Po_tpk_idx'.
at skyway.jdbc.base.BaseExceptions.createException(Unknown Source)
at skyway.jdbc.base.BaseExceptions.getException(Unknown Source)
at skyway.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown Source)
at skyway.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source)
at skyway.jdbc.sqlserver.tds.TDSRPCRequest.processReplyToken(Unknown Source)
at skyway.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source)
at skyway.jdbc.sqlserver.SQLServerImplStatement.getNextResultType(Unknown Source)
at skyway.jdbc.base.BaseStatement.commonTransitionToState(Unknown Source)
at skyway.jdbc.base.BaseStatement.postImplExecute(Unknown Source)
at skyway.jdbc.base.BasePreparedStatement.postImplExecute(Unknown Source)
at skyway.jdbc.base.BaseStatement.commonExecute(Unknown Source)
at skyway.jdbc.base.BaseStatement.executeUpdateInternal(Unknown Source)
at skyway.jdbc.base.BasePreparedStatement.executeUpdate(Unknown Source)
at com.sap.engine.services.dbpool.wrappers.PreparedStatementWrapper.executeUpdate(PreparedStatementWrapper.java:240)
at many2many0.PersistentM2M0.ejb_iInsert(PersistentM2M0.java:35)
at com.sap.engine.services.ejb.entity.pm.PersistentM2M.ejbFlush(PersistentM2M.java:127)
... 48 more
Hello Chad,
I assume the problem that you face is the one we have already fixed in the EJB Container. It concerns the following scenario:
1. A many-to-many relationship is updated in a certain transaction
2. A finder method is invoked in the same transaction - here the change in the relationship is stored in the DB by an insert statement in the join table
3. At transaction commit time all changed entities are stored in the DB and the EJB container attempts to store the changed relationship again. This results in the SQLException because of the duplicate rows.
The fix will be part of NW' 04 SP 13.
Indeed, a possible workaround is to use the <switch-off-storing/> tag in persistent.xml, unless it violates the business logic.
If you need an emergent patch, please create a CSS message.
Regards,
Svetoslav
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Chad,
we had the same problem. It is a bug into the EJB module of WebAS. Contact SAP and ask for a patch.
Regards André
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.