2 Replies Latest reply on Aug 27, 2004 10:20 AM by cyxs

    Inconsistencies of CMR collections

    cyxs Newbie


      I have to Entities, say house and person. The relation is many-to-many.

      I made some associations so that every person has one or more houses-

      So far the preconditions.

      I deleted all associations and then tried to find all persons without houses (which should return all persons).

      For this i used a my-sql finder query

      SELECT p FROM person p where p.houses IS EMPTY. (JBoss >= 3.2.4)


      SELECT p FROM person p , IN (p.houses) here p.houses IS EMPTY. (JBoss < 3.2.4)

      The finder method returns not a single person.

      It seems like the deletion of the association is not applied to the database immediatly or the finder-mthod did not recognize the change.

      Anyone elready encountered this problem?



        • 1. Re: Inconsistencies of CMR collections
          Collin Novice

          How are you deleting the associations? If your entity container configuration specifies commit option A, then deleting the associations from outside the container (using an SQL query) would cause this behavior.

          However, if you are iterating through each person entity and setting the associations that way...

          for (Iterator persons = personHome.findAll().iterator(); persons.hasNext();)
          Person p = (Person)persons.next();
          p.setHouses(new ArrayList());

          Then the container should reflect the disassociation.

          • 2. Re: Inconsistencies of CMR collections
            cyxs Newbie

            I ahave used an iterator and remove() and also the removeAll() method. The finder method simply doesnt get it. seems like the removing takes place after the method finishes. but before the method finishes, the finder method is called.

            I am using commit B option and also no transactions. Very weired.