title: EJB 3 Edit database record
body: <p>I have problem with updating a database record using EJB and JPA. Persistence provider: <code>org.eclipse.persistence.jpa.PersistenceProvider</code></p>
  
  <p>When I am creating a record I am using this method:</p>
  
  <pre><code>public void create(T entity) {
      getEntityManager().persist(entity);
  }
  </code></pre>
  
  <p>All is ok. Now I want to edit the the same record. For e.g. I have an entity:</p>
  
  <pre><code>@Entity
  @Table(name = "OPERATION")
  public class Operation implements Serializable {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Column(name = "ID")
      private Long id;
  
      @Column(name = "OPERATION_AUTHOR")
      private String operationAuthor;
  
      @Column(name = "OPERATION_TYPE")
      private String operationType;
  
      @Column(name = "OPERATION_STATUS")
      private String operationStatus;
  
      @Column(name = "CREATED")
      @Temporal(value = TemporalType.DATE)
      private Date created;
  
      @Column(name = "COMPLETED")
      @Temporal(value = TemporalType.DATE)
      private Date completed;  
  
      //Getters and setters
  }
  </code></pre>
  
  <p>For e.g. I want to update only <code>operationStatus</code>. I am creating an entity, setting to it the same record id and new <code>operationStatus</code>. For updating I am using this method:</p>
  
  <pre><code>public void edit(T entity) {
      getEntityManager().merge(entity);
  }
  </code></pre>
  
  <p>The problem is when I update the record the status is updated correctly but all the other columns' values are set to <code>null</code> not left as they were before. I want to update only <code>operationStatus</code> and left other values untouched. Is this possible to do this using EJB? And what should I change to make this happen?</p>