Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hi!!
I sometimes get the following exception: "Transaction (Process ID 63) was deadlocked..." (full stack trace below), when running the attached code.
This is the only code that touch the specific db table.
The reason (so I'm told by the original writers) for the call to refresh is some weird behaviour of Oracle when saving CLOB's and BLOB's (I guess they try to lock something for the duration of the blob load?)- This is probably the reason for the exception - but why.
Do you know of a problem in saving CLOB's/BLOB's in oracle?
Do you know of a better way to run this "save" code?
Sorry I can't be more specific as to the exact reason for the call to "flush" and the call to "refresh" ...
Thanks
Yariv Snapir
Hibernate version:
2.0
Mapping documents:
Code between sessionFactory.openSession() and session.close():
Code:
public static GeneratedImage saveImage(String name, byte[] imageData) {
Transaction tx = session.beginTransaction();
GeneratedImage image = new GeneratedImage();
image.setImageData(new byte[] {0x00});
image.setName(name);
session.save(image);
session.flush();
session.refresh(image, net.sf.hibernate.LockMode.UPGRADE);
image.setImageData(imageData);
tx.commit();
return image;
}
/**
* Load a GeneratedImage from DB and then deletes it (each image is used once - I think).
* @param imageName - the image to be loaded from DB and deleted after.
* @return Loaded image.
*/
public static GeneratedImage loadAndDeleteImage(String imageName){
Transaction tx = session.beginTransaction();
Query query = session.getNamedQuery("GeneratedImage.getByName");
query.setString("name", imageName);
GeneratedImage image = (GeneratedImage)query.list().get(0);
tx.commit();
return image;
}
Full stack trace of any exception that occurs:
java.sql.SQLException: Transaction (Process ID 63) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
at net.sourceforge.jtds.jdbc.SqlMessage.toSQLException(SqlMessage.java:392)
at net.sourceforge.jtds.jdbc.SQLWarningChain.addOrReturn(SQLWarningChain.java:99)
at net.sourceforge.jtds.jdbc.Tds.fetchRow(Tds.java:3722)
at net.sourceforge.jtds.jdbc.TdsResultSet.fetchNextRow(TdsResultSet.java:432)
at net.sourceforge.jtds.jdbc.TdsResultSet.internalFetchRows(TdsResultSet.java:765)
at net.sourceforge.jtds.jdbc.TdsResultSet.haveMoreResults(TdsResultSet.java:747)
at net.sourceforge.jtds.jdbc.TdsResultSet.next(TdsResultSet.java:391)
at org.jboss.resource.adapter.jdbc.WrappedResultSet.next(WrappedResultSet.java:530)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:200)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:836)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:856)
at net.sf.hibernate.loader.SimpleEntityLoader.load(SimpleEntityLoader.java:58)
at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:419)
at net.sf.hibernate.impl.SessionImpl.refresh(SessionImpl.java:2172)
at com.mercury.dashboard.arch.hibernate.Transaction.refresh(Transaction.java:108)
at com.mercury.dashboard.model.portlet.GeneratedImage.saveImage(GeneratedImage.java:78)
at com.mercury.dashboard.app.portlet.chart.ChartPortletController.saveImage(ChartPortletController.java:227)
at com.mercury.dashboard.app.portlet.chart.ChartPortletController.renderChart(ChartPortletController.java:96)
at org.apache.jsp.app.portlet.ChartPortlet_jsp._jspService(ChartPortlet_jsp.java:319)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:703)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:589)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:499)
at org.apache.pluto.core.impl.PortletRequestDispatcherImpl.include(PortletRequestDispatcherImpl.java:46)
at com.mercury.dashboard.app.portlet.BuilderPortlet.doView(BuilderPortlet.java:138)
at javax.portlet.GenericPortlet.doDispatch(GenericPortlet.java:250)
at javax.portlet.GenericPortlet.render(GenericPortlet.java:178)
at com.mercury.dashboard.app.portlet.DashboardPortlet.render(DashboardPortlet.java:46)
at org.apache.pluto.core.PortletServlet.dispatch(PortletServlet.java:240)
at org.apache.pluto.core.PortletServlet.doGet(PortletServlet.java:179)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.pluto.core.PortletServlet.service(PortletServlet.java:174)
at com.mercury.dashboard.app.portal.PortletWrapperServlet.service(PortletWrapperServlet.java:95)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:703)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:589)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:499)
at org.apache.pluto.invoker.impl.PortletInvokerImpl.invoke(PortletInvokerImpl.java:121)
at org.apache.pluto.invoker.impl.PortletInvokerImpl.render(PortletInvokerImpl.java:73)
at org.apache.pluto.PortletContainerImpl.renderPortlet(PortletContainerImpl.java:109)
at com.mercury.dashboard.app.portal.PortletManager.service(PortletManager.java:179)
at com.mercury.dashboard.app.portal.PortalServlet.service(PortalServlet.java:108)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:703)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:589)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:499)
at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:966)
at org.apache.jsp.app.portal.PortletFrame_jsp._jspService(PortletFrame_jsp.java:463)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:703)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:589)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:499)
at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:966)
at org.apache.jsp.app.portal.PageView_jsp._jspService(PageView_jsp.java:508)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:703)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312)
at com.mercury.dashboard.arch.host.util.DashboardFilterServlet.service(DashboardFilterServlet.java:108)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:703)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312)
at com.mercury.dashboard.arch.host.DashboardServlet.service(DashboardServlet.java:247)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at com.mercury.dashboard.arch.host.MultipartRequestFilter.applyFilter(MultipartRequestFilter.java:63)
at com.mercury.dashboard.arch.host.BaseFilter.doFilter(BaseFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at com.mercury.mycenter.authentication.MyCenterAuthenticationFilter.doFilter(MyCenterAuthenticationFilter.java:84)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:72)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.jboss.web.tomcat.security.JBossSecurityMgrRealm.invoke(JBossSecurityMgrRealm.java:275)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)
Name and version of the database you are using:
MSSQLServer 2000
The generated SQL (show_sql=true):
Can't reproduce with generated SQL - sinchronization problem
Debug level Hibernate log excerpt: