title: Issue with merge and delete javabeans
body: <p>Good evening , I'm trying to remove and update entity stored into a datatable,the application doesen't give me errors but de facto it doesen't merge and remove the record from the db</p>
  <p>May be the problem is in the entitymanager</p>
  <p>Someone could explain me what's i'm doing wrong?</p>
  <pre><code>&lt;p:commandButton value=&quot;Save&quot; icon=&quot;pi pi-check&quot; action=&quot;#{marcaController.creaMarca()}&quot;
                                   update=&quot;manage-product-content&quot; process=&quot;manage-product-content @this&quot;/&gt;
  //...
   &lt;p:commandButton value=&quot;Yes&quot; icon=&quot;pi pi-check&quot; action=&quot;#{marcaController.deleteMarca()}&quot;
                               process=&quot;@this&quot; oncomplete=&quot;PF('deleteProductDialog').hide()&quot;/&gt;
  </code></pre>
  <p>This is  MarcaController</p>
  <pre><code>    Marca m=new Marca();
      
      private static final long serialVersionUID = 1L;
      @EJB
      private MarcaDao marcaDao;
  
      
      public void openNew() {
          this.m = new Marca();
      }
      
      public Marca getSelected() {
          return m;
          
      }
      public void setSelected(Marca m) {
          this.m=m;
      }
      public void creaMarca() {
          
         if(m.getIdmarca()==null) {
              try {
                  marcaDao.create(m);
                  FacesMessage m = new FacesMessage
                          (FacesMessage.SEVERITY_INFO, &quot;Product created&quot;
                                  ,&quot;OK&quot;);
                  FacesContext.getCurrentInstance().addMessage(&quot;Success&quot;, m);
              } catch (Exception e) {
                  FacesMessage m = new FacesMessage
                          (FacesMessage.SEVERITY_ERROR, e.getMessage()
                                  ,&quot;KO&quot;);
                  FacesContext.getCurrentInstance().addMessage(&quot;Error&quot;, m);
                  
                  
              }
         }
         else {
          
             update();
             FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(&quot;Product Updated&quot;));
         }
      
          PrimeFaces.current().executeScript(&quot;PF('manageProductDialog').hide()&quot;);
          PrimeFaces.current().ajax().update(&quot;form:messages&quot;, &quot;form:dt-products&quot;);
          
      }
      public void update() {
          
          marcaDao.update(getSelected());
          
      }
      public  void deleteMarca() {
          Marca m1=m;
          
          marcaDao.deleteById(m1.getIdmarca());
          
          m=null;
          FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(&quot;Product Removed&quot;));
          PrimeFaces.current().ajax().update(&quot;form:messages&quot;, &quot;form:dt-products&quot;);
          
      }
  </code></pre>
  <p>This is   MarcaDao</p>
  <pre><code>@PersistenceContext(unitName = &quot;mio-persistence-unit&quot;)
      private EntityManager em;
  
      public void create(Marca entity) {
          em.persist(entity);
      }
  
      public void deleteById(Integer id) {
          
          Marca entity = em.find(Marca.class, id);
          if (entity != null) {
              em.remove(entity);
          }
      }
  
  
      public void update(Marca entity) {
          
          Marca m2 = em.find(Marca.class, entity.getIdmarca());
          
          em.merge(m2);
          
      }
  
  </code></pre>
  <p>Thank you in advance!</p>