You need to call kem.merge(p1); before flush
Chris
-----Original Message-----
From: davidautentico
Sent: 31/05/2010 17:44:42
Subject: tomcat6+openjpa+jsf
Hi
I have problems to update any entity in my database with openjpa in a jsf
enviroment with Tomcat6 as server.
When I executed this simply code:
....
EntityManagerFactory factory = Persistence.
createEntityManagerFactory("person",System.getProperties());
EntityManager em = factory.createEntityManager();
OpenJPAEntityManager kem = OpenJPAPersistence.cast(em);
kem.getTransaction().begin();
Person p1 = new Person();
p1.setIdPerson(1);
p1.setMail("mail1");
p1.setName("p1");
kem.persist(p1);//WORKS OK
endTx(kem);
Person fx = kem.find(Person.class, 1);
kem.getTransaction().begin();
if (fx!=null){
fx.setMail("ea");
kem.flush(); //ERROR: trying to update database
.....
I get an error when the flush() instruction is executed:
<openjpa-2.0.0-r422266:935683 fatal store error>
org.apache.openjpa.persistence.OptimisticLockException: Optimistic locking
errors were detected when flushing to the data store. The following objects
may have been concurrently modified in another transaction:
[coreservlets.Person-1] FailedObject: coreservlets.Person-1
[java.lang.String]
I really dont know how to update an entity previously persisted, I always
get an Optimistic locking error.
Thanks
--
View this message in context:
http://openjpa.208410.n2.nabble.com/tomcat6-openjpa-jsf-tp5120836p5120836.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.