4 Replies Latest reply on Dec 28, 2004 5:17 AM by epbernard

    CascadeType

    smallnest

      if EntityBean A use an associated entityBean B,

      1. CascadeType.CREATE
      when A is created,persistent context will create associated B

      2. CascadeType.MERGE
      when A is merged,persistent context will merge associated B

      3.CascadeType.REMOVE
      when A is removed,persistent context will removed associated B

      4.CascadeType.ALL
      when A is created/merged/removed,persistent context will rcreated/merged/removed associated B

      Cascade looks like "pass"

        • 1. Re: CascadeType
          mduffy_lists

          Hmmm.....

          This seems oddly limited.

          Assume I have a table of users and a table of role types and a mapping table for a many to many associaition. My role types are a limited set that does not change (very often).

          If I create a user I just want to creat the user and a mapping to an existing role type. I do not want to create a new role type.

          Similarly, when I delete a user I just want to delete the user and the mapping, I do not want to delete the role type, which is mapped to other users.

          Can someone please clarify cascade type.

          Thx.

          Mike

          • 2. Re: CascadeType
            kabirkhan

            If you don't want cascading to occur then do not specify a cascade value in your @ManyToMany, @OneToMany or @ManyToOne. This should resolve to cascade="none" in the underlying Hibernate mapping.

            • 3. Re: CascadeType
              mduffy_lists

              Thx.

              My mistake.

              The EJB 3.0 SPec in section, "10.1.12 ManyToOne Annotation", clearly states that the default is, "No operations are cascaded."

              Mike

              • 4. Re: CascadeType
                epbernard

                Actually the cascade semantic is a bit more subtle.
                Read the 6.3 chapter of the spec for more infos