Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » IntegrityConstraintViolationException when merging new entity in derby
IntegrityConstraintViolationException when merging new entity in derby [message #640692] Mon, 22 November 2010 15:20 Go to next message
Christian Eugster is currently offline Christian Eugster
Messages: 134
Registered: July 2009
Location: St. Gallen Switzerland
Senior Member
Hi,

i am using a derby database in embedded mode. When i try to merge a new entity into the database, i get an integrity constraint violation exception, because of a duplicate key in primary key. i store the entity with null value in primary key (that is of type Long).

as primary key generation strategy i use GenerationType.TABLE. in the table there is an entry for the primary key of the table in question. it is updated regularly after each trial. also the entity gets a value when merging. the exception occures when the transaction commit is done.

the SQL101122190016090 (see stack trace below) is the primary key of the table.

have you any hints, what i could do wrong?

Stored server: ch.eugster.colibri.persistence.model.ProductGroup - 483 - 0

[EL Warning]: 2010-11-22 21:00:37.787--UnitOfWork(6784961)--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.1.1.v20100817-r8050): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLIntegrityConstraintViolationException: 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 'SQL101122190016090' defined on 'COLIBRI_PRODUCT_GROUP'.
Error Code: 20000
Call: INSERT IGNORE INTO colibri_product_group (pg_id, pg_update, pg_mapping_id, pg_fc_round_factor, pg_code, pg_product_group_type, pg_deleted, pg_version, pg_timestamp, pg_name, pg_account, pg_price, pg_quantity, pg_option, pg_fc_quotation, pg_pt_id, pg_tx_id, pg_cs_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
bind => [483, 0, , 0.05, Einlage CHF, 4, 0, 1, 1290456037436, Einlage CHF, , 0.0, 0, 0, 1.0, 1, 1, 1]
Query: InsertObjectQuery(ch.eugster.colibri.persistence.model.ProductGroup@800012e2)
[EL Warning]: 2010-11-22 21:00:37.797--UnitOfWork(6784961)--javax.persistence.Persist enceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.1.1.v20100817-r8050): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLIntegrityConstraintViolationException: 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 'SQL101122190016090' defined on 'COLIBRI_PRODUCT_GROUP'.
Re: IntegrityConstraintViolationException when merging new entity in derby [message #640727 is a reply to message #640692] Mon, 22 November 2010 17:32 Go to previous message
Christian Eugster is currently offline Christian Eugster
Messages: 134
Registered: July 2009
Location: St. Gallen Switzerland
Senior Member
Sorry, it is my error, while committing i did a query.
Previous Topic:Entity.getChildList().add(childEntity) :child entity is not persisted.
Next Topic:EclipseLink/Examples/JPA/RCP
Goto Forum:
  


Current Time: Wed Aug 20 20:42:25 EDT 2014

Powered by FUDForum. Page generated in 0.02064 seconds