A fix is available
APAR status
Closed as program error.
Error description
Caused by: <openjpa-2.2.1-SNAPSHOT-r422266:1325904 fatal store error> org.apache.openjpa.persistence.EntityExistsException: ORA-00001: unique constraint (MYSCHEMA.PK_JPASAMPLE) violated {prepstmnt 1943831144 INSERT INTO JPASAMPLE (id, data) VALUES (?, ?) [params=?, ?]} [code=1, state=23000] FailedObject: com.ibm.yyy.sample.jpa.Sample@46ce45cd at org.apache.openjpa.jdbc.sql.DBDictionary.narrow(DBDictionary.jav a:4909) at org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDic tionary. java:4884) java:136) at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions .java:78 ) pl.flushBatch(BatchingPreparedStatementManagerImpl.java:221) at org.apache.openjpa.jdbc.kernel.BatchingConstraintUpdateManager.f lush(Bat chingConstraintUpdateManager.java:63) ctUpdateManager.java:103) at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(Abstr actUpdat eManager.java:76) nager.java:713) at org.apache.openjpa.kernel.DelegatingStoreManager.flush(Delegatin gStoreMa nager.java:131)
Local fix
No work around seen at this time but target to be fixed in next release.
Problem summary
**************************************************************** * USERS AFFECTED: All users of IBM WebSphere Application * * Server * * Liberty Profile * **************************************************************** * PROBLEM DESCRIPTION: A DuplicateKeyException/unique * * constraint * * violation occurs when using a JPA * * SequenceGenerator. * **************************************************************** * RECOMMENDATION: * **************************************************************** Take the following sample JPA Entity: @Table(name = "JPASAMPLE") public class Sample implements Serializable { @Id @SequenceGenerator(name = "IDGENERATOR_JPASAMPLE", sequenceName = "SEQ_JPASAMPLE") @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "IDGENERATOR_JPASAMPLE") private int id; This defined a SequenceGenerator with a GenerationType of SEQUENCE, which means JPA will use a sequence from the database in use. OpenJPA will attempt to generate the following SQL when first allocating values for the sequence: ALTER SEQUENCE SEQ_JPASAMPLE INCREMENT BY 50 Note that the value '50' in the above SQL is OpenJPA's 'allocationSize'. An 'ALTER' command requires special database permissions to be allowed to run against a database. When OpenJPA runs the ALTER command, if the current user doesn't have permission to alter the sequence, the command will fail. When this fails, OpenJPA does not properly handled this failure and does not properly manage the sequence values it expects compared to that which the database maintains. For some time (up to 'allocationSize') OpenJPA will properly insert instances of the 'Sample' entity but once the 'allocationSize' + 1 (51 in this case) is reached, OpenJPA's sequence value will become out of synch with that which the database expects. OpenJPA should get the next sequence from the database, instead it uses an already used sequence value. This results in the following exception: com.ibm.websphere.ce.cm.DuplicateKeyException: ORA-00001: unique constraint (ID) violated ....... java.sql.SQLIntegrityConstraintViolationException: ORA-00001: unique constraint (ID) violated
Problem conclusion
With this fix, code has been added to OpenJPA to ensure that it properly handles a failed 'ALTER SEQUENCE' command and properly handles its sequence values. The fix for this APAR is currently targeted for inclusion in fix pack 8.5.0.2. Please refer to the Recommended Updates page for delivery information: http://www.ibm.com/support/docview.wss?rs=180&uid=swg27004980
Temporary fix
Comments
APAR Information
APAR number
PM80448
Reported component name
LIBERTY PROFILE
Reported component ID
5724J0814
Reported release
850
Status
CLOSED PER
PE
NoPE
HIPER
NoHIPER
Special Attention
NoSpecatt
Submitted date
2013-01-11
Closed date
2013-03-06
Last modified date
2013-03-06
APAR is sysrouted FROM one or more of the following:
APAR is sysrouted TO one or more of the following:
Fix information
Fixed component name
LIBERTY PROFILE
Fixed component ID
5724J0814
Applicable component levels
R850 PSY
UP
[{"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSEQTP","label":"WebSphere Application Server"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"850","Line of Business":{"code":"LOB45","label":"Automation"}}]
Document Information
Modified date:
29 October 2021