openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Curtis <curti...@gmail.com>
Subject Re: Issue with Update
Date Thu, 06 Aug 2009 20:18:13 GMT

Radhika -

Do you have a version field on your Entity? If so, make sure that you merge
that value also.

- Rick

On Thu, Aug 6, 2009 at 2:33 PM, Radhika (via Nabble) <
ml-user+261810-195546051@n2.nabble.com<ml-user%2B261810-195546051@n2.nabble.com>
> wrote:

> No,
>
> As part of my business service, I call
> EmployerDAO.findByProperty(EmployerID) .
>
> I get the employer entity and I
> map this employer entity to a model object called Employer which I then
> send to my front end.
> the user updates some employer details.
>
> I map my updated model object into a new Employer Entity object and then do
> EntityManager.merge(entity). The entity parameter is my employer entity.
> In between the mappings, I maintain the employer ID which is my primary key
> , the same.
>
> When I do an update, there are 2 records created.
>
> Radhika
>
>
>
> Rick Curtis wrote:
> Where is the Entity coming from that you pass into
> EntityManager.merge(entity)? (Are you calling em.find(..) and then updating
> the Entity?)
>
> -Rick
>
> Radhika wrote:
> Hi,
>
> I have an issue with update entity in openjpa. For example, I have a table
> Employer , and entity employer and the corresponding DAO is EmployerDAO.
>
>
> To add a new employer record, I call
> EmployerDAO.save(Employer) which inturn uses
> getEntityManager().persist(entity);
> This works fine.
>
> Now to update this employer record, I call EmployerDAO.update(Employer)
> which in turn calls
> getEntityManager().merge(entity).
>
> When I call at my database table, I have 2 records with the same employer
> id. For testing purpose, I have disabled the primary key contraints.  At the
> same time, I get a JPA exception that I am trying to enter multiple records
> with same employer id.
>
> Why does a new record get created instead of updating a previous one?
>
> Please could you help me out.
>
> Radhika
>
>
>
> ------------------------------
>  View message @
> http://n2.nabble.com/Issue-with-Update-tp3399573p3400317.html
> To unsubscribe from Re: Issue with Update, click here< (link removed) >.
>
>
>

-- 
View this message in context: http://n2.nabble.com/Issue-with-Update-tp3399573p3400506.html
Sent from the OpenJPA Developers mailing list archive at Nabble.com.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message