Trails

hasCyclicRelationships solution is merging on entities not persisted yet

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.0.0
  • Fix Version/s: 1.1.0
  • Component/s: None
  • Labels:
    None
  • Environment:
    XP Pro, Eclipse, Java5
  • Number of attachments :
    0

Description

hasCyclicRelationships solution is merging on entities not persisted yet.

This is stopping OneToOne development.

org.apache.hivemind.ApplicationRuntimeException
Failure invoking listener method 'public void org.trails.page.EditPage.saveAndReturn(org.apache.tapestry.IRequestCycle)' on $EditPage_68@19cec59[DefaultEdit]: cannot copy a reference to an object with a null id
component: $EditPage_68@19cec59[DefaultEdit]
location: context:/WEB-INF/DefaultEdit.page, line 2, column 54
1 <!DOCTYPE page-specification PUBLIC "-//Apache Software Foundation//Tapestry Specification 4.0//EN" "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">
2 <page-specification class="org.trails.page.EditPage">
3 <property name="model" persist="session"/>
4 <property name="nextPage" />
5
6 <property name="delegator"/>
7

org.hibernate.AssertionFailure
cannot copy a reference to an object with a null id
messages: cannot copy a reference to an object with a null id

throwableCount: 1
throwables: org.hibernate.AssertionFailure: cannot copy a reference to an object with a null id

Stack Trace:
org.hibernate.type.EntityType.replace(EntityType.java:255)
org.hibernate.type.AbstractType.replace(AbstractType.java:153)
org.hibernate.type.TypeFactory.replaceAssociations(TypeFactory.java:530)
org.hibernate.event.def.DefaultMergeEventListener.copyValues(DefaultMergeEventListener.java:366)
org.hibernate.event.def.DefaultMergeEventListener.entityIsTransient(DefaultMergeEventListener.java:195)
org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:123)
org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:53)
org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:677)
org.hibernate.impl.SessionImpl.merge(SessionImpl.java:661)
org.hibernate.impl.SessionImpl.merge(SessionImpl.java:665)
org.springframework.orm.hibernate3.HibernateTemplate$23.doInHibernate(HibernateTemplate.java:760)
org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:367)
org.springframework.orm.hibernate3.HibernateTemplate.merge(HibernateTemplate.java:757)
org.trails.hibernate.HibernatePersistenceService.save(HibernatePersistenceService.java:124)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:585)
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:281)
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:187)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:154)
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:210)
$Proxy32.save(Unknown Source)
org.trails.page.EditPage.save(EditPage.java:79)
org.trails.page.EditPage.saveAndReturn(EditPage.java:141)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:585)
org.apache.tapestry.listener.ListenerMethodInvokerImpl.invokeTargetMethod(ListenerMethodInvokerImpl.java:214)
org.apache.tapestry.listener.ListenerMethodInvokerImpl.invokeListenerMethod(ListenerMethodInvokerImpl.java:155)
org.apache.tapestry.listener.ListenerMethodInvokerImpl.searchAndInvoke(ListenerMethodInvokerImpl.java:124)
org.apache.tapestry.listener.ListenerMethodInvokerImpl.invokeListenerMethod(ListenerMethodInvokerImpl.java:69)
org.apache.tapestry.listener.SyntheticListener.actionTriggered(SyntheticListener.java:51)
org.apache.tapestry.listener.ListenerInvokerTerminator.invokeListener(ListenerInvokerTerminator.java:51)
$ListenerInvoker_111754c2134.invokeListener($ListenerInvoker_111754c2134.java)
org.apache.tapestry.form.AbstractSubmit.handleClick(AbstractSubmit.java:81)
org.apache.tapestry.form.AbstractSubmit.rewindFormComponent(AbstractSubmit.java:49)
org.apache.tapestry.form.AbstractFormComponent.renderComponent(AbstractFormComponent.java:114)
org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:617)
org.apache.tapestry.AbstractComponent.renderBody(AbstractComponent.java:434)
org.apache.tapestry.components.IfBean.renderComponent(IfBean.java:86)
org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:617)
org.apache.tapestry.AbstractComponent.renderBody(AbstractComponent.java:434)
org.apache.tapestry.components.Any.renderComponent(Any.java:48)
org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:617)
org.apache.tapestry.BaseComponent.renderComponent(BaseComponent.java:92)
org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:617)
org.apache.tapestry.AbstractComponent.renderBody(AbstractComponent.java:434)
org.apache.tapestry.form.FormSupportImpl.rewind(FormSupportImpl.java:573)
org.apache.tapestry.form.Form.renderComponent(Form.java:226)
org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:617)
org.apache.tapestry.form.Form.rewind(Form.java:327)
org.apache.tapestry.engine.RequestCycle.rewindForm(RequestCycle.java:439)
org.apache.tapestry.form.Form.trigger(Form.java:338)
org.apache.tapestry.engine.DirectService.triggerComponent(DirectService.java:146)
org.apache.tapestry.engine.DirectService.service(DirectService.java:132)
$IEngineService_111754c2198.service($IEngineService_111754c2198.java)
org.apache.tapestry.services.impl.EngineServiceOuterProxy.service(EngineServiceOuterProxy.java:66)
org.apache.tapestry.engine.AbstractEngine.service(AbstractEngine.java:248)
org.apache.tapestry.services.impl.InvokeEngineTerminator.service(InvokeEngineTerminator.java:60)
$WebRequestServicer_111754c216c.service($WebRequestServicer_111754c216c.java)
org.trails.i18n.LocaleFilter.service(LocaleFilter.java:26)
$WebRequestServicerFilter_111754c216a.service($WebRequestServicerFilter_111754c216a.java)
$WebRequestServicer_111754c216e.service($WebRequestServicer_111754c216e.java)
com.javaforge.tapestry.tapernate.filter.TapernateFilter.service(TapernateFilter.java:81)
$WebRequestServicerFilter_111754c2168.service($WebRequestServicerFilter_111754c2168.java)
$WebRequestServicer_111754c216e.service($WebRequestServicer_111754c216e.java)
$WebRequestServicer_111754c2164.service($WebRequestServicer_111754c2164.java)
org.apache.tapestry.services.impl.WebRequestServicerPipelineBridge.service(WebRequestServicerPipelineBridge.java:56)
$ServletRequestServicer_111754c214a.service($ServletRequestServicer_111754c214a.java)
org.apache.tapestry.request.DecodedRequestInjector.service(DecodedRequestInjector.java:55)
$ServletRequestServicerFilter_111754c2146.service($ServletRequestServicerFilter_111754c2146.java)
$ServletRequestServicer_111754c214c.service($ServletRequestServicer_111754c214c.java)
org.apache.tapestry.multipart.MultipartDecoderFilter.service(MultipartDecoderFilter.java:52)
$ServletRequestServicerFilter_111754c2144.service($ServletRequestServicerFilter_111754c2144.java)
$ServletRequestServicer_111754c214c.service($ServletRequestServicer_111754c214c.java)
org.apache.tapestry.services.impl.SetupRequestEncoding.service(SetupRequestEncoding.java:53)
$ServletRequestServicerFilter_111754c2148.service($ServletRequestServicerFilter_111754c2148.java)
$ServletRequestServicer_111754c214c.service($ServletRequestServicer_111754c214c.java)
$ServletRequestServicer_111754c213e.service($ServletRequestServicer_111754c213e.java)
org.apache.tapestry.ApplicationServlet.doService(ApplicationServlet.java:123)
org.apache.tapestry.ApplicationServlet.doPost(ApplicationServlet.java:168)
javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:491)
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1074)
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:173)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1065)
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:365)
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:185)
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:689)
org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:391)
org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:146)
org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
org.mortbay.jetty.Server.handle(Server.java:285)
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:457)
org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:765)
org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:628)
org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:203)
org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:357)
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:329)
org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:475)

Activity

Hide
Pablo Gra\~na added a comment -

Is there some sample to reproduce the error?

Show
Pablo Gra\~na added a comment - Is there some sample to reproduce the error?
Hide
Ken in nashua added a comment -

Hi Pablo,

Based on my recollection... this stack trace was produce by coding your pojo.

Specifically, create a virutual implicit bidirectional relationship OneToOne or Collections...

Configure owning side to have hasCyclicRelationships=true

Omit hasCyclicRelationships on client side

Now see if stack trace is procuded.

I neglect to recall the order. But there is a coding case whereby the stack trace is produced... WHY? because code is in place to operate merge on anything it encounters. Look at the merge code and see. There is no logic to determine whether an enitty is transient... or at least for the merge stuff.

Show
Ken in nashua added a comment - Hi Pablo, Based on my recollection... this stack trace was produce by coding your pojo. Specifically, create a virutual implicit bidirectional relationship OneToOne or Collections... Configure owning side to have hasCyclicRelationships=true Omit hasCyclicRelationships on client side Now see if stack trace is procuded. I neglect to recall the order. But there is a coding case whereby the stack trace is produced... WHY? because code is in place to operate merge on anything it encounters. Look at the merge code and see. There is no logic to determine whether an enitty is transient... or at least for the merge stuff.
Hide
Alejandro Scandroli added a comment -

Mental note: PersistenceService should provide a method with the same functionality than isModelNew.
To avoid the use of DescriptorService inside the PersistenceService I think the new method could take a IClassDescriptor as a parameter.

Show
Alejandro Scandroli added a comment - Mental note: PersistenceService should provide a method with the same functionality than isModelNew. To avoid the use of DescriptorService inside the PersistenceService I think the new method could take a IClassDescriptor as a parameter.
Hide
Alejandro Scandroli added a comment -

fixed in svn rev 765

Show
Alejandro Scandroli added a comment - fixed in svn rev 765

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: