2 Replies Latest reply on May 19, 2005 10:02 AM by Jan Bares

    Entity removal

    Jan Bares Newbie

      Hi,

      in JSR-220, chapter 2.3.2 about entity bean removal, it is not mentioned what happens to entity Y, if X is managed/new entity with relation to Y and the relation is not annotated with cascade=REMOVE or cascade=ALL.

      When you look to the next chapter 2.3.3, sychronization with db, there is written, that in the case above, Y is synchronized if X owns the relationship.

      Does it mean that when there is no cascade=REMOVE or cascade=ALL, the Y will not be removed?

      Thanks, Jan

        • 2. Re: Entity removal
          Jan Bares Newbie

          Thanks for reply, but it doesn't work as expected (or I don't understand the JSR-220).

          Suppose the relation listed in http://www.jboss.org/index.html?module=bb&op=viewtopic&t=64136 with optional=false. There is no cascade on Child.

          This code fails with "deleted object would be re-saved by cascade (remove deleted object from associations)":

          (on client)
          familyDAO.remove(1L);
          
          (server)
          public void remove(Long id) {
           manager.remove(find(Child.class, id));
          }
          


          However this code works fine:
          (on client)
          familyDAO.remove(familyDAO.loadChild(1L));
          
          (on server)
          public Child loadChild(Long id) {
           return manager.find(Child.class, id);
          }
          
          public void remove(Object object) {
           manager.remove(object);
          }
          


          Where is the difference?

          Thanks for any comment. Is there anything to read about cascading/associations of EJB3.0 besides the JSR-220?

          Jan