0 Replies Latest reply on Nov 29, 2002 4:22 AM by Daniel Georges

    Can't update an entity bean oout of a servlet

    Daniel Georges Newbie

      Hi all!

      I get a strange behaviour of an entity bean in JBoss 2.4.1a. The problem is that I want to update an entity bean. I wrote a System.ou.t println in the setter-Method of this bean. The value is correct, but if I read this value with the getter-Method the old value is returned. The strange thin is, from my app-client everything works fine. Any hints about that.

      The Bean is like that

      public class UserBean implements EntityBean
      protected EntityContext entityContext;

      //primaryKey fields
      public String client;
      public String userid;

      //mandatory fields
      public String password;

      //optional fields
      public Date pwduration;
      public String loginattempts;

      public UserBeanPK ejbCreate(BeanData data) throws CreateException
      // Objektstatus setzen
      this.client= data.getStringAttribute("client");
      this.userid= data.getStringAttribute("userid");

      this.password= data.getStringAttribute("password");

      return null;

      public void ejbPostCreate(BeanData data){}
      public void ejbActivate() {}
      public void ejbLoad() {}
      public void ejbPassivate() {}
      public void ejbRemove() throws RemoveException {}
      public void ejbStore() {}
      public void setEntityContext(EntityContext ctx) {
      // Keep the entity context in object
      entityContext = ctx;
      public void unsetEntityContext() {
      entityContext = null;

      /*========================= User implementation ============================*/

      public void setUserData(BeanData data)
      this.password= data.getStringAttribute("password");

      this.pwduration= data.getDateAttribute("pwduration");
      loginattempts= data.getStringAttribute("loginattempts");

      public BeanData getUserData()
      BeanData data = new BeanData();
      //Primary fields

      //Mandatory fields

      //Optional fields

      return data;

      and is accessed from a class within a servlet
      try {
      UserBeanPK pk = new UserBeanPK(
      User bean = ((UserHome) de.xifs.helper.ReferenceHolder.getReference("User")).findByPrimaryKey(pk);
      catch(Exception e) {
      throw new Exception("Failed to edit User by primary key"+e.toString());
      Any hints.
      Greetings Dan