openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cil-Gamir <hannes.visa...@rmb.co.za>
Subject [SOLVED] Re: Locking Exception after Persisting new entity
Date Thu, 12 Nov 2009 11:33:09 GMT

Answering my own question

It turns out... when I save an existing object I must flush the entity
manager before persisting. On creating I should not flush. 

    public final void create(Object o) {
        getEntityManager().getTransaction().begin();
        getEntityManager().persist(o);
        getEntityManager().getTransaction().commit();
    }
    
    public final void update(Object o) {
        getEntityManager().getTransaction().begin();
        getEntityManager().persist(o);
        getEntityManager().flush();
        getEntityManager().getTransaction().commit();
    }

In the past I was using the create method (called save at the time) for
updating and saving.

Thanks
-- 
View this message in context: http://n2.nabble.com/Locking-Exception-after-Persisting-new-entity-tp3992010p3992165.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Mime
View raw message