Friday, January 20, 2012

Re: How to Update Entity with Editors & RequestFactory

Thx for your response,

I solved it using merge instead of persist :

entityManager.merge(articulo);
//entityManager.persist(articulo);

Hope it helps

On 20 ene, 00:41, -sowdri- <sow...@gmail.com> wrote:
> This usually doesn't happen, as the entities with existing id will be only
> merged rather than creating the new instance. Try checking your equals and
> hashcode implementations for 'Articulo' class, as that plays a central role
> in merge mechanism.
>
> If you still want a workaround,
>
> public void persistArticulo(Articulo articulo)
>     {
>             try {
>                         EntityManager entityManager = entityManager();
>                         entityManager.getTransaction().begin();
>                         // if articule.id != null, merge
>                         // else persist
>                         entityManager.persist(articulo);
>                         entityManager.getTransaction().commit();
>                         entityManager.close();
>                         return ;
>                 }

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment