0 Replies Latest reply on Sep 22, 2003 5:46 AM by tsangcn

    entityContext.getEJBLocalObject() returns wrong object for e

    tsangcn

      Hello,

      I am using JBoss3.2.1 with JDK 1.4.2. I encountered the following problem and seems it is a bug in JBoss.

      I have an entity bean called GroupBean defined as :

      public abstract class GroupBean implements EntityBean {
      public javax.ejb.EntityContext entityContext;

      public void setEntityContext(javax.ejb.EntityContext ctx) {
      this.entityContext = ctx;
      }

      ......

      public int getMembersCount() throws FinderException {
      Collection c = ejbSelectMemberIds((GroupLocal)entityContext.getEJBLocalObject());
      }

      public abstract Collection ejbSelectMemberIds(GroupLocal group) throws FinderException;

      public abstract Integer getId();
      public abstract void setId();

      ......

      }

      The ejb-ql is sometime like

      SELECT m.id FROM Group g, IN (g.members) m
      WHERE g = ?1

      GroupLocal is the local interface of GroupBean.
      id is its primary key.

      In the above coding, the method getMemebersCount() sometimes returns wrong number. In extensive debug, I found that the ejbSelectMemberIds() method sometimes return values for another GroupBean.

      When I put a log statement in getMembersCount, and I found the sometimes the value return from getId() and entityContext.getEJBLocalObject().getPrimaryKey() are different. The value returned from getId() is always correct, but the value returned from entityContext.getEJBLocalObject().getPrimaryKey() is sometimes wrong and it is the primary key for anthoer GroupBean.

      I used the word sometimes because the failure occurs intermittently. I cannot figure out how the failure occurs.

      If I changed my coding to

      public int getMembersCount() throws FinderException {
      Collection c = ejbSelectMemberIds(getId());
      }

      public abstract Collection ejbSelectMemberIds(Integer id) throws FinderException;


      SELECT m.id FROM Group g, IN (g.members) m
      WHERE g.id = ?1

      then it works fine.


      So, I conclude that entityContext.getEJBLocalObject() returns a wrong local interface for another entity bean under some unknown situation.

      Is this a bug in JBoss3.2.1?

      Anyone knows if there is a fix for this?

      Thanks

      CN