users@glassfish.java.net

Re: GF/Hibernate save without calling save explicitely?

From: Laird Nelson <ljnelson_at_gmail.com>
Date: Tue, 22 Nov 2011 13:49:20 -0500

On Tue, Nov 22, 2011 at 1:43 PM, <forums_at_java.net> wrote:

> I am using GF 2 and container managed persistence with Hibernate 3.2 as
> provider. I have some finder method in my business logic, which manipulates
> some persistent entities, which have been fetched via the EntityManager.
> The
> manipulation is just changing a String property (deleting an element from a
> collection leads to the same effect). I do not call anything like save or
> persist on my EntityManager. I just want to return some changed entities to
> my client.
>

In this case, just before you do any modifications, call
entityManager.detach(theEntity). That will fix your problem, but you won't
understand why unless you read the JPA specification, which is probably a
good idea anyway. :-)

Best,
Laird

-- 
http://about.me/lairdnelson