1 Reply Latest reply on Nov 16, 2004 6:10 AM by nproemper

    Multiple instances of an entity

    nproemper

      Hi all,
      I found out, that JBoss 4 creates multiple instances (=Entity Beans) of one entity. This results in problems during update, because the changes, which are made, are overwritten by an subsequent ejbStore() call of another EJB of the same entity.
      Did anyone face the same problem? Is there any solution for it or should I kick the whole development in the trash bin?

      Hereby I give you the most important part from the protocol. The relevant bean is RelationshipBean, its key is (objtyFr, objidFr, objtyTo, objidTo, lfdNr),
      (relty, validFr, validTo) are attributes.

      Any help is appreciated.

      Nick

      2004-11-16 09:11:14,261 DEBUG [de.btconsult.crm.ejb.RelationshipBean] ejbActiviate()
      2004-11-16 09:11:14,261 DEBUG [de.btconsult.crm.ejb.RelationshipBean] ejbLoad()
      2004-11-16 09:11:14,261 DEBUG [de.btconsult.crm.ejb.RelationshipBean] objtyFr=KU;objidFr=0000000111;objtyTo=ZI;lfdNr=0001;relty=A003;validFr=2001-01-01;validTo=2004-12-31
      2004-11-16 09:11:14,261 DEBUG [de.btconsult.crm.ejb.RelationshipBean] ejbStore()
      2004-11-16 09:11:14,261 DEBUG [de.btconsult.crm.ejb.RelationshipBean] objtyFr=KU;objidFr=0000000111;objtyTo=ZI;lfdNr=0001;relty=A003;validFr=2001-01-01;validTo=2004-12-01
      2004-11-16 09:11:14,271 DEBUG [de.btconsult.crm.ejb.RelationshipTypeBean] ejbStore()
      2004-11-16 09:11:14,271 DEBUG [de.btconsult.crm.ejb.RelationshipBean] ejbStore()
      2004-11-16 09:11:14,271 DEBUG [de.btconsult.crm.ejb.RelationshipBean] objtyFr=KU;objidFr=0000000111;objtyTo=ZI;lfdNr=0001;relty=A003;validFr=2001-01-01;validTo=2004-12-31

        • 1. Re: Multiple instances of an entity
          nproemper

          Hi all,

          the problem still exists and is making me mad, but I have found out some details, which I want to add for your understanding.
          I try show you what happens in a kind of sequence diagram:

          a) Servlet calls RelationshipoBean->setData
          b) setData creates an instance of RelationshipTypeBean via findByPrimaryKey
          c) setData calls RelationshipTypeBean->checkValidity
          d) checkValidity searchs for other Relationship through calling findByObjTo
          e) for each found entity checks are made. In case of success nothing happens, in case of an error an exception is thrown.

          The problem resides in point e), because the finder returns the instance, too, which is active over all the sequence. And taking the Bean's interfaces out of the collection returned by the finder results in another instance of the SAME entity.

          The documentation says, that this behaviour is impossible!? See here for a snipplet from "JBoss Admin Development Guide 3.2.6"

          5.4.2. Entity Bean Lifecycle

          With the default configuration of JBoss there is only one active instance of a given entity bean in memory at one time.