What is the behavior difference between the following two in terms of
the records in the database ?

I realize that the Java identity of the e is different between the two
below, but I am not sure about the
how openjpa treats these two option.

1.) Find an instance and assign a new one to it
public void updateMyEntity(data)
   throws Exception {
        EntityManager em = factory.createEntityManager();
        MyEntity e = em.find(MyEntity.class, id);
        e = new MyEntity(data);
}

2.) Find and instance and update its fields
public void updateMyEntity(data)
   throws Exception {
        EntityManager em = factory.createEntityManager();
        MyEntity e = em.find(MyEntity.class, id);
        e.setA(data.getA());
}



Reply via email to