2 Replies Latest reply on Apr 2, 2007 10:18 PM by horikawa yoji

    setter updates the DB

    horikawa yoji Newbie

      Hi fellaz.

      my company decided to develop a web app using EJB 3.0 but I'm facing a prob.

      I hav a Entity as follows:

      @Entity
      public class StatusMassAd implements Serializable {
      @Id
      @Column(name="massAd_id")
      private int id;

      private int status;

      public int getId() {
      return id;
      }
      public int getStatus() {
      return status;
      }
      public void setStatus(int status) {
      this.status = status;
      }
      }

      When I use this entity to "setStatus", it updated the DB record after transaction ended.
      The book I have says (or I assume it says) that the EJB will NOT update the DB unless I call the EntityManager's "merge" method.

      I would like to update the DB ONLY if the merge method is called.

      Anyone know how I can stop updating the DB when I use "setters"?