If you don't call persist(e) or otherwise attach e to a managed graph,
the first example will do nothing.
-Patrick
On 11/6/07, Gul Onural <[EMAIL PROTECTED]> wrote:
>
> 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());
> }
>
>
>
>
--
Patrick Linskey
202 669 5907