These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: no collection snapshot for orphan delete
PostPosted: Fri Feb 08, 2008 11:58 am 
Newbie

Joined: Tue Nov 22, 2005 10:08 am
Posts: 17
Hibernate version: 3.2.5

Hibernate throws this:

an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)

That's the assertion:


org.hibernate.AssertionFailure: no collection snapshot for orphan delete

Can someone put me on the right track to figure it out? What does it mean: 'no collection snapshot for orphan delete' ?

That's the full stack trace:

2008-02-08 15:50:33,170 [resin-tcp-connection-respub.gucode.gnl:6802-65] ERROR org.hibernate.AssertionFailure - an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
org.hibernate.AssertionFailure: no collection snapshot for orphan delete
at org.hibernate.engine.CollectionEntry.getOrphans(CollectionEntry.java:348)
at org.hibernate.engine.Cascade.deleteOrphans(Cascade.java:340)
at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:324)
at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:242)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:219)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
at org.hibernate.engine.Cascade.cascade(Cascade.java:130)
at org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:131)
at org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:122)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:65)
at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:35)
at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:969)
at org.hibernate.impl.SessionImpl.executeNativeUpdate(SessionImpl.java:1158)
at org.hibernate.impl.SQLQueryImpl.executeUpdate(SQLQueryImpl.java:334)
at com.gu.r2.common.model.content.poll.repository.PollDAO.incrementCounts(PollDAO.java:74)
at com.gu.r2.common.model.content.poll.repository.PollDAO.incrementQuestionCounts(PollDAO.java:66)
at com.gu.r2.common.model.content.poll.repository.PollRepository.incrementPollQuestionsAndAnswerCounts(PollRepository.java:28)
at com.gu.r2.frontend.controller.poll.PollSubmissionController.vote(PollSubmissionController.java:115)
at com.gu.r2.frontend.controller.poll.PollSubmissionController.submitAnswer(PollSubmissionController.java:50)
at com.gu.r2.frontend.controller.poll.PollSubmissionController$$FastClassByCGLIB$$85479a85.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:696)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:631)
at com.gu.r2.frontend.controller.poll.PollSubmissionController$$EnhancerByCGLIB$$6755622a.submitAnswer(<generated>)
at sun.reflect.GeneratedMethodAccessor677.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.web.servlet.mvc.multiaction.MultiActionController.invokeNamedMethod(MultiActionController.java:472)
at org.springframework.web.servlet.mvc.multiaction.MultiActionController.handleRequestInternal(MultiActionController.java:409)
at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:874)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:808)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:476)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:431)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:115)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:92)
at com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:106)
at com.gu.r2.common.webutil.ForceUtf8CharacterEncodingFilter.doFilterInternal(ForceUtf8CharacterEncodingFilter.java:27)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:70)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:70)
at com.gu.r2.common.webutil.RequestLoggingFilter.doFilterInternal(RequestLoggingFilter.java:35)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:70)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:63)
at com.gu.r2.common.spring.GURequestContextFilter.doFilterInternal(GURequestContextFilter.java:31)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:70)
at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:178)
at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:229)
at com.caucho.server.hmux.HmuxRequest.handleRequest(HmuxRequest.java:419)
at com.caucho.server.port.TcpConnection.run(TcpConnection.java:389)
at com.caucho.util.ThreadPool.runTasks(ThreadPool.java:507)
at com.caucho.util.ThreadPool.run(ThreadPool.java:433)
at java.lang.Thread.run(Thread.java:619)
2008-02-08 15:50:33,173 [resin-tcp-connection-respub.gucode.gnl:6802-65] ERROR com.gu.r2.common.webutil.RequestLoggingFilter - Request for /pages/Guardian/users/poll/submitanswer pollId=330883824&q-1138=a-1316 caused exception after 4 ms.
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.hibernate.AssertionFailure: no collection snapshot for orphan delete
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:488)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:431)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:115)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:92)
at com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:106)
at com.gu.r2.common.webutil.ForceUtf8CharacterEncodingFilter.doFilterInternal(ForceUtf8CharacterEncodingFilter.java:27)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:70)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:70)
at com.gu.r2.common.webutil.RequestLoggingFilter.doFilterInternal(RequestLoggingFilter.java:35)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:70)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:63)
at com.gu.r2.common.spring.GURequestContextFilter.doFilterInternal(GURequestContextFilter.java:31)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:70)
at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:178)
at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:229)
at com.caucho.server.hmux.HmuxRequest.handleRequest(HmuxRequest.java:419)
at com.caucho.server.port.TcpConnection.run(TcpConnection.java:389)
at com.caucho.util.ThreadPool.runTasks(ThreadPool.java:507)
at com.caucho.util.ThreadPool.run(ThreadPool.java:433)
at java.lang.Thread.run(Thread.java:619)
Caused by: org.hibernate.AssertionFailure: no collection snapshot for orphan delete
at org.hibernate.engine.CollectionEntry.getOrphans(CollectionEntry.java:348)
at org.hibernate.engine.Cascade.deleteOrphans(Cascade.java:340)
at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:324)
at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:242)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:219)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
at org.hibernate.engine.Cascade.cascade(Cascade.java:130)
at org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:131)
at org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:122)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:65)
at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:35)
at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:969)
at org.hibernate.impl.SessionImpl.executeNativeUpdate(SessionImpl.java:1158)
at org.hibernate.impl.SQLQueryImpl.executeUpdate(SQLQueryImpl.java:334)
at com.gu.r2.common.model.content.poll.repository.PollDAO.incrementCounts(PollDAO.java:74)
at com.gu.r2.common.model.content.poll.repository.PollDAO.incrementQuestionCounts(PollDAO.java:66)
at com.gu.r2.common.model.content.poll.repository.PollRepository.incrementPollQuestionsAndAnswerCounts(PollRepository.java:28)
at com.gu.r2.frontend.controller.poll.PollSubmissionController.vote(PollSubmissionController.java:115)
at com.gu.r2.frontend.controller.poll.PollSubmissionController.submitAnswer(PollSubmissionController.java:50)
at com.gu.r2.frontend.controller.poll.PollSubmissionController$$FastClassByCGLIB$$85479a85.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:696)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:631)
at com.gu.r2.frontend.controller.poll.PollSubmissionController$$EnhancerByCGLIB$$6755622a.submitAnswer(<generated>)
at sun.reflect.GeneratedMethodAccessor677.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.web.servlet.mvc.multiaction.MultiActionController.invokeNamedMethod(MultiActionController.java:472)
at org.springframework.web.servlet.mvc.multiaction.MultiActionController.handleRequestInternal(MultiActionController.java:409)
at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:874)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:808)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:476)
... 24 more


Top
 Profile  
 
 Post subject: Re: no collection snapshot for orphan delete
PostPosted: Fri Feb 08, 2008 12:42 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
What is the code that is causing this? From the error description I can tell you have delete-orphan cascade option on one of the collections and somehow hibernate does not have a snapshot of that collection so that it knows what is missing in the collection.



Farzad-


Top
 Profile  
 
 Post subject: Re: no collection snapshot for orphan delete
PostPosted: Tue Feb 12, 2008 7:00 am 
Newbie

Joined: Tue Nov 22, 2005 10:08 am
Posts: 17
After few hours debugging session with Hibernate we found the problem. We manually (e.g. in java code) alter hibernate configuration by setting some collection mappings to be immutable. Something like that:
Code:
for (Iterator<Collection> iter = configuration.getCollectionMappings(); iter.hasNext();) {
    Collection collection = iter.next();
    collection.setMutable(false);
}


Unfortunately, some of the collection mappings in xml files were defined with cascade="delete-orphan"

delete-orphan style of cascading doesn't work with immutable collections. Assertion error is thrown whenever session is flushed.

So, if you define collection mappings like that:

mutable="false" cascade="delete-orphan"

you will face assertion error on flush. Perhaps hibernate should fail-fast during configuring SessionFactory? Is it a bug? Throwing nicer exception like "you cannot cascade changes from immutable collection ... " + some info how to fix it would be great :)

We fixed our problem by removing cascade from immutable collections (it's a bit hackey, though):

Code:
collection.setMutable(false);
String propertyName = collection.getNodeName();
collection.getOwner().getProperty(propertyName).setCascade("none");


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.