|
|
|
Mukta Vishwanath Divekar
|
Hello, My project is doing its initial database operations through OpenJPA. And it has to perform rest of the operations through JDBC. Data insertion in a table is happening through OpenJPA. But when the same inserted data is queried through JDBC its not available it seems since entire process is a part of single transaction. Is there any way using which we can commit the transaction in between and continue the JDBC operation in a single process. Instead of creating a new JDBC connection, I tried creating connection like : EntityManager em = emf.createEntityManager(); broker = (Broker) JPAFacadeHelper.toBroker(em); JDBCStore store = (JDBCStore)broker.getStoreManager(); conn = store.getConnection(); By providing persistence unit name to 'EntityManagerFactory' but it gave me exception like: javax.persistence.PersistenceException: Provider error. Provider: org.apache.openjpa.persi stence.PersistenceProviderImpl at javax.persistence.Persistence.createFactory(Persistence.java:176) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:112) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:66) at com.symcor.pcbi.irx.icre.fileconversion.ICREDataProcessorImpl.isTableDataMoved( ICREDataProcessorImpl.java:117) at com.symcor.pcbi.irx.icre.fileconversion.ICREFileParserImpl.processICREFiles(ICR EFileParserImpl.java:285) at com.symcor.pcbi.irx.icre.fileconversion.ICREFileParserImpl.process(ICREFilePars erImpl.java:147) at com.symcor.pcbi.irx.icre.fileconversion.ICREFacade.initiateProcess(ICREFacade.j ava:57) at com.symcor.pcbi.irx.icre.timer.IRXTimer.startTimer(IRXTimer.java:135) at com.symcor.pcbi.irx.icre.timer.IRXTimer.initializeTimer(IRXTimer.java:104) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.ja va:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invo ke(ReflectionInvocationContext.java:146) at org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(Reflect ionInvocationContext.java:129) at org.apache.openejb.core.interceptor.InterceptorStack.invoke(InterceptorStack.ja va:67) at org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer .java:203) at org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer. java:165) at org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(EjbObjectProxy Handler.java:211) at org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(EjbObjectProxyHandler .java:65) at org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java :244) at org.apache.openejb.util.proxy.Jdk13InvocationHandler.invoke(Jdk13InvocationHand ler.java:49) at $Proxy45.initializeTimer(Unknown Source) at com.symcor.pcbi.irx.icre.servlet.IRXTimerServlet.init(IRXTimerServlet.java:38) at javax.servlet.GenericServlet.init(GenericServlet.java:215) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1053) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:955) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:403 5) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4338) at org.apache.geronimo.tomcat.GeronimoStandardContext.access$201(GeronimoStandardC ontext.java:60) at org.apache.geronimo.tomcat.GeronimoStandardContext$SystemMethodValve.invoke(Ger onimoStandardContext.java:343) at org.apache.geronimo.tomcat.valve.GeronimoBeforeAfterValve.invoke(GeronimoBefore AfterValve.java:47) at org.apache.geronimo.tomcat.GeronimoStandardContext.start(GeronimoStandardContex t.java:196) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525) at org.apache.geronimo.tomcat.TomcatContainer.addContext(TomcatContainer.java:355) at org.apache.geronimo.tomcat.TomcatContainer$$FastClassByCGLIB$$9370b073.invoke(< generated>) at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53) at org.apache.geronimo.gbean.runtime.FastMethodInvoker.invoke(FastMethodInvoker.ja va:38) at org.apache.geronimo.gbean.runtime.GBeanOperation.invoke(GBeanOperation.java:124 ) at org.apache.geronimo.gbean.runtime.GBeanInstance.invoke(GBeanInstance.java:830) at org.apache.geronimo.gbean.runtime.RawInvoker.invoke(RawInvoker.java:57) at org.apache.geronimo.kernel.basic.RawOperationInvoker.invoke(RawOperationInvoker .java:35) at org.apache.geronimo.kernel.basic.ProxyMethodInterceptor.intercept(ProxyMethodIn terceptor.java:96) at org.apache.geronimo.tomcat.TomcatContainer$$EnhancerByCGLIB$$78a8e440.addContex t(<generated>) at org.apache.geronimo.tomcat.TomcatWebAppContext.doStart(TomcatWebAppContext.java :524) at org.apache.geronimo.gbean.runtime.GBeanInstance.createInstance(GBeanInstance.ja va:996) at org.apache.geronimo.gbean.runtime.GBeanInstanceState.attemptFullStart(GBeanInst anceState.java:268) at org.apache.geronimo.gbean.runtime.GBeanInstanceState.start(GBeanInstanceState.j ava:102) at org.apache.geronimo.gbean.runtime.GBeanInstance.start(GBeanInstance.java:539) at org.apache.geronimo.gbean.runtime.GBeanDependency.attemptFullStart(GBeanDepende ncy.java:111) at org.apache.geronimo.gbean.runtime.GBeanDependency.addTarget(GBeanDependency.jav a:146) at org.apache.geronimo.gbean.runtime.GBeanDependency$1.running(GBeanDependency.jav a:120) at org.apache.geronimo.kernel.basic.BasicLifecycleMonitor.fireRunningEvent(BasicLi fecycleMonitor.java:176) at org.apache.geronimo.kernel.basic.BasicLifecycleMonitor.access$300(BasicLifecycl eMonitor.java:44) at org.apache.geronimo.kernel.basic.BasicLifecycleMonitor$RawLifecycleBroadcaster. fireRunningEvent(BasicLifecycleMonitor.java:254) Thanks n regards, Mukta. **************** CAUTION - Disclaimer ***************** This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the addressee(s). If you are not the intended recipient, please notify the sender by e-mail and delete the original message. Further, you are not to copy, disclose, or distribute this e-mail or its contents to any other person and any such actions are unlawful. This e-mail may contain viruses. Infosys has taken every reasonable precaution to minimize this risk, but is not liable for any damage you may sustain as a result of any virus in this e-mail. You should carry out your own virus checks before opening the e-mail or attachment. Infosys reserves the right to monitor and review the content of all messages sent to or from this e-mail address. Messages sent to or from this e-mail address may be stored on the Infosys e-mail system. ***INFOSYS******** End of Disclaimer ********INFOSYS*** |
|||||||||||||||
|
Srinivas Sastry
|
Hi Mukta,
The below code will work for getting Connection from EntityManager: DelegatingConnection deConn = (DelegatingConnection)OpenJPAPersistence.*cast *(getEntityManager()).getConnection(); conn = deConn.getInnermostDelegate(); Directly typecasting to EntityManager (in first statement) without using DelegatingConnection is throwing ClassCastException (something like CMPEntityManagerTxScoped cannot be cast to Connection). On 7/22/08, Mukta Vishwanath Divekar <Mukta_Divekar@...> wrote: > > > Hello, > > > My project is doing its initial database operations through OpenJPA. And > it has to perform rest of the operations through JDBC. > Data insertion in a table is happening through OpenJPA. But when the same > inserted data is queried through JDBC its not available it seems since > entire process is a part of single transaction. Is there any way using which > we can commit the transaction in between and continue the JDBC operation in > a single process. > > Instead of creating a new JDBC connection, I tried creating connection like > : > > EntityManager em = emf.createEntityManager(); > broker = (Broker) JPAFacadeHelper.toBroker(em); > JDBCStore store = (JDBCStore)broker.getStoreManager(); > conn = store.getConnection(); > > By providing persistence unit name to 'EntityManagerFactory' but it gave me > exception like: > > javax.persistence.PersistenceException: Provider error. Provider: > org.apache.openjpa.persi > stence.PersistenceProviderImpl > at javax.persistence.Persistence.createFactory(Persistence.java:176) > at > javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:112) > at > javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:66) > at > com.symcor.pcbi.irx.icre.fileconversion.ICREDataProcessorImpl.isTableDataMoved( > ICREDataProcessorImpl.java:117) > at > com.symcor.pcbi.irx.icre.fileconversion.ICREFileParserImpl.processICREFiles(ICR > EFileParserImpl.java:285) > at > com.symcor.pcbi.irx.icre.fileconversion.ICREFileParserImpl.process(ICREFilePars > erImpl.java:147) > at > com.symcor.pcbi.irx.icre.fileconversion.ICREFacade.initiateProcess(ICREFacade.j > ava:57) > at > com.symcor.pcbi.irx.icre.timer.IRXTimer.startTimer(IRXTimer.java:135) > at > com.symcor.pcbi.irx.icre.timer.IRXTimer.initializeTimer(IRXTimer.java:104) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.ja > va:25) > at java.lang.reflect.Method.invoke(Method.java:597) > at > org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invo > ke(ReflectionInvocationContext.java:146) > at > org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(Reflect > ionInvocationContext.java:129) > at > org.apache.openejb.core.interceptor.InterceptorStack.invoke(InterceptorStack.ja > va:67) > at > org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer > .java:203) > at > org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer. > java:165) > at > org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(EjbObjectProxy > Handler.java:211) > at > org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(EjbObjectProxyHandler > .java:65) > at > org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java > :244) > at > org.apache.openejb.util.proxy.Jdk13InvocationHandler.invoke(Jdk13InvocationHand > ler.java:49) > at $Proxy45.initializeTimer(Unknown Source) > at > com.symcor.pcbi.irx.icre.servlet.IRXTimerServlet.init(IRXTimerServlet.java:38) > at javax.servlet.GenericServlet.init(GenericServlet.java:215) > at > org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1053) > > at > org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:955) > at > org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:403 > 5) > at > org.apache.catalina.core.StandardContext.start(StandardContext.java:4338) > at > org.apache.geronimo.tomcat.GeronimoStandardContext.access$201(GeronimoStandardC > ontext.java:60) > at > org.apache.geronimo.tomcat.GeronimoStandardContext$SystemMethodValve.invoke(Ger > onimoStandardContext.java:343) > at > org.apache.geronimo.tomcat.valve.GeronimoBeforeAfterValve.invoke(GeronimoBefore > AfterValve.java:47) > at > org.apache.geronimo.tomcat.GeronimoStandardContext.start(GeronimoStandardContex > t.java:196) > at > org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791) > > at > org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) > at > org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525) > at > org.apache.geronimo.tomcat.TomcatContainer.addContext(TomcatContainer.java:355) > > at > org.apache.geronimo.tomcat.TomcatContainer$$FastClassByCGLIB$$9370b073.invoke(< > generated>) > at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53) > at > org.apache.geronimo.gbean.runtime.FastMethodInvoker.invoke(FastMethodInvoker.ja > va:38) > at > org.apache.geronimo.gbean.runtime.GBeanOperation.invoke(GBeanOperation.java:124 > ) > at > org.apache.geronimo.gbean.runtime.GBeanInstance.invoke(GBeanInstance.java:830) > at > org.apache.geronimo.gbean.runtime.RawInvoker.invoke(RawInvoker.java:57) > at > org.apache.geronimo.kernel.basic.RawOperationInvoker.invoke(RawOperationInvoker > .java:35) > at > org.apache.geronimo.kernel.basic.ProxyMethodInterceptor.intercept(ProxyMethodIn > terceptor.java:96) > at > org.apache.geronimo.tomcat.TomcatContainer$$EnhancerByCGLIB$$78a8e440.addContex > t(<generated>) > at > org.apache.geronimo.tomcat.TomcatWebAppContext.doStart(TomcatWebAppContext.java > :524) > at > org.apache.geronimo.gbean.runtime.GBeanInstance.createInstance(GBeanInstance.ja > va:996) > at > org.apache.geronimo.gbean.runtime.GBeanInstanceState.attemptFullStart(GBeanInst > anceState.java:268) > at > org.apache.geronimo.gbean.runtime.GBeanInstanceState.start(GBeanInstanceState.j > ava:102) > at > org.apache.geronimo.gbean.runtime.GBeanInstance.start(GBeanInstance.java:539) > at > org.apache.geronimo.gbean.runtime.GBeanDependency.attemptFullStart(GBeanDepende > ncy.java:111) > at > org.apache.geronimo.gbean.runtime.GBeanDependency.addTarget(GBeanDependency.jav > a:146) > at > org.apache.geronimo.gbean.runtime.GBeanDependency$1.running(GBeanDependency.jav > a:120) > at > org.apache.geronimo.kernel.basic.BasicLifecycleMonitor.fireRunningEvent(BasicLi > fecycleMonitor.java:176) > at > org.apache.geronimo.kernel.basic.BasicLifecycleMonitor.access$300(BasicLifecycl > eMonitor.java:44) > at > org.apache.geronimo.kernel.basic.BasicLifecycleMonitor$RawLifecycleBroadcaster. > fireRunningEvent(BasicLifecycleMonitor.java:254) > > Thanks n regards, > Mukta. > > > > > **************** CAUTION - Disclaimer ***************** > This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended > solely > for the use of the addressee(s). If you are not the intended recipient, > please > notify the sender by e-mail and delete the original message. Further, you > are not > to copy, disclose, or distribute this e-mail or its contents to any other > person and > any such actions are unlawful. This e-mail may contain viruses. Infosys has > taken > every reasonable precaution to minimize this risk, but is not liable for > any damage > you may sustain as a result of any virus in this e-mail. You should carry > out your > own virus checks before opening the e-mail or attachment. Infosys reserves > the > right to monitor and review the content of all messages sent to or from > this e-mail > address. Messages sent to or from this e-mail address may be stored on the > Infosys e-mail system. > ***INFOSYS******** End of Disclaimer ********INFOSYS*** > |
|||||||||||||||
| Free Forum Powered by Nabble | Forum Help |