3 Replies Latest reply on Aug 21, 2002 10:55 AM by rgrey

    CMP2.0 and storing objects problem

    rune

      I'am using JBoss 3.0.0alpha and the new CMP 2.0 implementation, and I have problem storing ArrayList as a BLOB in MySQL. I have done this often with previous versions of JBoss and it has been working fine all the time. When I am creating a bean with a ArrayList cmr field all seem to work fine. The values seems to be stored and the size is correct. But when I later fetched the bean using either findAll or findByPrimaryKey, all fields in the bean are correct except for the ArrayList. It has now the size of zero. Have I missed something that is new with CMP2.0 (and JBoss 3.0.0alpha) or is this a possible bug ?

      Rune Hamnvik
      Mobinor AS
      Norway

        • 1. Re: CMP2.0 and storing objects problem
          dsundstrom

          Can you send me a small test case? I'll try to look into this.

          • 2. Re: CMP2.0 and storing objects problem
            rgrey

            Was this problem ever resolved? I am using an older version of JBoss (2.X) and wondered if an upgrade would resolve this. Thanks

            • 3. Re: CMP2.0 and storing objects problem
              rgrey

              Please ignore my other post, I think the answer to this dilemma lies in your getter. When an ArrayList is initially returned from the EJB it is complete because it has come fresh from the database. However, Java dynamic collections like ArrayLists and Vectors are only references (as far as I can tell). In other words, when the receiving client destroys the ArrayList it is also destroyed in the EJB. I resolved this problem with code like this:

              public ArrayList getArrayList() {
              ArrayList temp = (ArrayList) arrayList.clone();
              return temp;
              }

              Please correct me if this is an incorrect resolution to your problem.