0 Replies Latest reply on Apr 15, 2005 3:29 PM by Yevgeny Shakhnovich

    1:n relationship and child deletion

    Yevgeny Shakhnovich Newbie

      I have a very simple basic question and hope somebody will answer it.

      Why in one to many relationship when I delete a child, the container looks for the parent in DB?

      Example: two beans, Customer and Account, where Customer may have a few accounts. Customer bean has a CMR field
      Collection getAccounts();
      Account has some field pointing to the parent.
      The relation can be unidirectional or bidirectional. It does not matter.

      When I delete an account, after deletion the ACCOUNT row in DB (child), JBoss selects the parent CUSTOMER row in DB.
      Why? I know that according to the spec, container must destroy the relationship, but what really it means? There is nothing in the parent row in DB that resembles the child. CMR Collection field is not persistent. Therefore, there is nothing to modify in the parent row in DB.
      Does it modify anything in memory? I hope CMR Collection field is not populated until I create an iterator to read it. Am I wrong?
      Actually, I even did not access the parent bean at all, so I assume it is not in the cache.
      So, what is the reason for such behavior? Is there any option to change it?

      I use JBoss 3.2.7.

      Thanks,
      Yevgeny