title: JPA updation not reflect on db
body: <p>we use entities are</p>
  
  <pre><code>public class User  implements Cloneable,Serializable{
  
      @Id
      @GeneratedValue
      protected long id;
  
      @NotNull
      protected String userName;
  
      @NotNull
      protected String email;
  
      @NotNull
      protected String firstName;
  
      @NotNull
      protected String lastName;
  
      @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
      @JoinColumn(name = "UserID", referencedColumnName = "ID")
      protected List&lt;UserCompanyRoles&gt; userRoles; 
  }
  public class UserCompanyRoles implements Serializable {
  
      private static final long serialVersionUID = 1L;
      private final static Logger logger = Logger.getLogger(UserCompanyRoles.class);
      @Id
      @GeneratedValue
      private long id;
  
      @OneToOne(fetch = FetchType.EAGER)
      @JoinColumn(name = "UserID")
      private User user;
  
      @OneToOne(fetch = FetchType.EAGER)
      @JoinColumn(name = "RoleID")
      private Role role;
  
  
      @OneToOne(fetch = FetchType.EAGER)
      @JoinColumn(name = "CompanyID")
      private Company company;
  }
  </code></pre>
  
  <p>this entity  user update by using dao</p>
  
  <pre><code>protected boolean update(Object entity,Long id) {
          EntityManager entityManager = null;
          EntityTransaction tx = null;
          try {
              entityManager = this.createEM();
              tx = entityManager.getTransaction();
              tx.begin();
              Object objToUpdate = retrieve(entity.getClass(), id);
              BeanUtils.copyProperties(objToUpdate, entity);
              entityManager.merge(objToUpdate);
              entityManager.flush();
              tx.commit();
              return true;
          } catch (Exception e1) {
              if (tx != null) {
                  tx.rollback();
              }
              return false;
          } finally {
              if(tx!=null){
                  tx.rollback();
              }
              if (entityManager != null &amp;&amp; entityManager.isOpen()) {
                  this.closeEM(entityManager);
              }
          }
      }
  </code></pre>
  
  <p>this code works for some time but. some time that newly added usercompanyrole not inserted into table.
  they could not throw error on time of updation.
  that will only some time other wise it will work good.
  we have no idea to solve this problem.
  that will be work good after restarting my server.</p>