openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Curtis <>
Subject Re: Issue in Handling persistent objects across multiple persistence contexts
Date Mon, 09 Mar 2009 15:52:52 GMT

Ram -
When you want to write your detached Entity back to the DB, are you using
EntityManager.merge(..)? If not, I'd give that a try.


Ram.sankar wrote:
> Hi,
> In my application i have a requirement that eventhough i change the values
> of persistent objects available in the session directly using getter and
> setter methods i have to save only the objects on which the 
> EntityManager.persist() is invoked explicitly. To resolve this problem we
> maintain 2 managers one for read and another for write. I detach the
> object from the read entity manager and merge the same with the write
> entity manager before calling a persist(). 
> The problem here is that OpenJPA is generating an insert query to save the
> persistent object eventhough it exists in the table. This is giving me an
> Unique constraint violated error. Is there anyway to tell OpenJPA to check
> for the existence of record with same primary key before persisting. Any
> help is highly appreciated.
> Regards,
> Ram

View this message in context:
Sent from the OpenJPA Users mailing list archive at

View raw message