Hi,

My OpenJPA app inserts the entity correctly the 1st time, but when it's 
updated, it tries to insert it again causing a data integrity exception. See 
the exception message below. I'm using em.merge() to do the update (as well 
as the initial add). The entity key does not change between the add and 
update.

Can anyone offer some suggestions as to what would cause a situation like 
this? Anyone else run across this? How did you fix it?

I'm using OpenJPA 1.0.1 with Derby 10.2.2.0 and Spring's JPA support (2.0.7)

ROOT CAUSE EXCEPTION MESSAGE
----------------------------
Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: The statement 
was aborted because it would have caused a duplicate key value in a unique or 
primary key constraint or unique index identified by 'SQL071203083750550' 
defined on 'CRUNCHERINFO'. {prepstmnt 18605439 INSERT INTO CruncherInfo 
(serviceURL, accessKey, adminUrl, agentId, commonName, lastRegistration, 
osname, SERVICE_VALUE, state, stateKey, CRUNCHERSTATUS_VALUE) VALUES 
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [params=(String) 
http://dellberry.cliftonfarm.net:7302, (String) bogus-accesskey, (String) 
http://dellberry.cliftonfarm.net:6322, (String) dellberry.cliftonfarm.net, 
(String) TestName_1, (Timestamp) 2008-01-25 21:02:09.512, (String) Linux, 
(String) TESTTYPE, (String) STOPPED, (String) cruncher.state.stopped, 
(String) DEAUTHORIZED]} [code=20000, state=23505]

----------------------------
BTW: SQL071203083750550 is:

ALTER TABLE "APP"."CRUNCHERINFO" ADD CONSTRAINT "SQL071203083750550" PRIMARY 
KEY ("SERVICEURL");

Reply via email to