1 Reply Latest reply on Jun 6, 2006 3:53 PM by William DeCoste

    StatefulSessionBean.someMethod returns Entity, other then st

    antonvk Newbie

       

      public class StatefulSession1Bean implements StatefulSession1, Serializable
      {
       @PersistenceContext
       private EntityManager manager;
       private Entity1 entity;
      
       public Entity1 createEntity1() {
       entity = new Entity1();
       return entity;
       }
      
       public boolean checkEqPointer(Entity1 entity) {
       return entity == this.entity;
       }
      
       public boolean checkEqEquals(Entity1 entity) {
       return entity.equals(this.entity);
       }
      }
      


      Futher code is called from a JSP:
      InitialContext ctx = new InitialContext();
      StatefulSession1 sess = (StatefulSession1) ctx.lookup("StatefulSession1Bean/remote");
      
       Entity1 ent1 = sess.createEntity1();
      
       out.println("checkEqPointer: " + sess.checkEqPointer(ent1));
       out.println("checkEqEquals: " + sess.checkEqEquals(ent1));
      


      checkEqPointer (so called JVM equality) always returns "false"
      checkEqEquals (DB equality) returns "true" if Entity1.equals is written correctly

      Is it correct that checkEqPointer returns false? If yes, please give the reference to the section in EJB3 spec.