core icon indicating copy to clipboard operation
core copied to clipboard

Relationship between contents are not updated/deleted when its definition is updated

Open joseorsini opened this issue 12 years ago • 6 comments

Reproduced in 2.5.6 and in client. Steps to reproduce:

  1. Create Structures A and B.
  2. Create a 1:N Relationship between these structures, being A the Parent Structure and B the Child one. Mark "Parent required" on the Relationship definition.
  3. Create contents for Structures A and B.
  4. Relate a piece of content between these structures.
  5. Edit the relationship and invert the Structures. Now B is the parent and A is the child. "Parent required" is still checked.
  6. Save the relationship.

Notes:

Existing relationships will remain in database. After reindexing, the relationship between contents from A (previously labeled as Parent) and B (former child) is still there, despite the order has changed in the Relationship definition. Trying to delete it from the content's "Relationships" tab returns an error message:

2014-11-26 21:23:43,769 ERROR com.dotmarketing.factories.TreeFactory - deleteTree failed:com.dotmarketing.exception.DotHibernateException: Error deleting object
com.dotmarketing.exception.DotHibernateException: Error deleting object
    at com.dotmarketing.db.HibernateUtil.delete(HibernateUtil.java:219)
    at com.dotmarketing.factories.TreeFactory.deleteTree(TreeFactory.java:280)
    at com.dotcms.content.elasticsearch.business.ESContentletAPIImpl.deleteUnrelatedContents(ESContentletAPIImpl.java:1635)
    at com.dotcms.content.elasticsearch.business.ESContentletAPIImpl.relateContent(ESContentletAPIImpl.java:1683)
    at com.dotcms.content.elasticsearch.business.ESContentletAPIImpl.moveContentDependencies(ESContentletAPIImpl.java:2725)
    at com.dotcms.content.elasticsearch.business.ESContentletAPIImpl.checkin(ESContentletAPIImpl.java:2236)
    at com.dotcms.content.elasticsearch.business.ESContentletAPIImpl.checkin(ESContentletAPIImpl.java:1967)
    at com.dotmarketing.portlets.contentlet.business.ContentletAPIInterceptor.checkin(ContentletAPIInterceptor.java:166)
    at com.dotmarketing.portlets.contentlet.business.web.ContentletWebAPIImpl._saveWebAsset(ContentletWebAPIImpl.java:519)
    at com.dotmarketing.portlets.contentlet.business.web.ContentletWebAPIImpl.saveContent(ContentletWebAPIImpl.java:129)
    at com.dotmarketing.portlets.contentlet.ajax.ContentletAjax.saveContent(ContentletAjax.java:1337)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.directwebremoting.impl.CreatorModule$1.doFilter(CreatorModule.java:229)
    at org.directwebremoting.impl.CreatorModule.executeMethod(CreatorModule.java:241)
    at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:379)
    at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:332)
    at org.directwebremoting.dwrp.BaseCallHandler.handle(BaseCallHandler.java:104)
    at org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:120)
    at org.directwebremoting.servlet.DwrServlet.doPost(DwrServlet.java:141)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:404)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at com.dotmarketing.filters.CMSFilter.doFilter(CMSFilter.java:126)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at com.dotmarketing.filters.AutoLoginFilter.doFilter(AutoLoginFilter.java:61)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at com.dotmarketing.filters.CacheImagesFilter.doFilter(CacheImagesFilter.java:47)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at com.dotmarketing.cms.urlmap.filters.URLMapFilter.doFilter(URLMapFilter.java:85)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at com.dotmarketing.filters.TimeMachineFilter.doFilter(TimeMachineFilter.java:162)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at com.dotmarketing.filters.CharsetEncodingFilter.doFilter(CharsetEncodingFilter.java:146)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:465)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:555)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Thread.java:745)
Caused by: net.sf.hibernate.HibernateException: SQL insert, update or delete failed (row not found)
    at net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:25)
    at net.sf.hibernate.persister.EntityPersister.delete(EntityPersister.java:581)
    at net.sf.hibernate.impl.ScheduledDeletion.execute(ScheduledDeletion.java:29)
    at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2449)
    at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2435)
    at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2397)
    at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2261)
    at com.dotmarketing.db.HibernateUtil.delete(HibernateUtil.java:217)
    ... 58 more

joseorsini avatar Nov 26 '14 21:11 joseorsini

we need to discuss what to do here but I wonder if this shouldn't be editable in this way

jtesser avatar Nov 26 '14 22:11 jtesser

@jtesser - agreed. I think you should have to "drop" the relationship. It is key that we clean up the tree table and index as well.

On Wed, Nov 26, 2014 at 5:13 PM, Jason Tesser [email protected] wrote:

we need to discuss what to do here but I wonder if this shouldn't be editable in this way

— Reply to this email directly or view it on GitHub https://github.com/dotCMS/core/issues/6753#issuecomment-64718347.

3250 Mary Street Suite 405 Miami, FL 33133 Main: 305-900-2001 | Direct: 978.294.9429

[email protected] | dotcms.com http://www.dotcms.com/

https://twitter.com/dotcms http://www.linkedin.com/company/dotcms https://plus.google.com/+Dotcms https://www.facebook.com/dotCMS

dotcmsCodeReview avatar Nov 29 '14 23:11 dotcmsCodeReview

I think the only things that could be editable from a relationship are the relation type (One to Many or Many to Many) and the checkboxes for requiring (or not) a Parent/Child Content. Selected structures and the Parent/Child relation names shouldn't be available for editing, otherwise it will break all existing relationships between contents.

joseorsini avatar Dec 02 '14 22:12 joseorsini

Reproduced in 3.2. By changing the Relationship Type from N-M to 1-N also breaks relationships between contents.

  • Info: https://my.dotcms.com/ticket/dotcms-38

joseorsini avatar May 27 '15 16:05 joseorsini

@joseorsini for sure we know about this one. I think the one that was in question was #7777

jtesser avatar May 27 '15 16:05 jtesser

Closing this one since it's a duplicated of related ticket.

joseorsini avatar Feb 28 '17 15:02 joseorsini