Hello

I have run into a problem which seems to be a bug in cayenne. I have tried several approaches in order to isolate the direct cause, thinking it is some kind of misconfiguration in my code, yet no luck.


Using  cayenne 3.0, derby (not tested on other db so far).
My cayenne model defines an entity called SiteTagRelation, inheriting from TagRelation. TagRelation is based on database entity with two important fields: entityRecordId and entityIdentifier. The latter is used for inheritance, identifying the type of TagRelation, the former is used as foreign key. Both fields are mandatory, and there is an unique index on the TagRelation table, created with following : CREATE UNIQUE INDEX TagRelation_unique ON TagRelation (nodeId, entityIdentifier, entityRecordId)

For this example the final relationships are as follow: Site -< SiteTagRelation >- Tag

Now a simple scenario of:
- getting a context
- fetching a Site
- deleting one SiteTagRelation using objectContext.deleteObject()
- re-creating new SiteTagRelation to the same Tag and Site using objectContext.newObject()

At this moment the context contains:
  Tag, persistent state = committed
  Site, persistent state = committed
  SiteTagRelation, persistent state = deleted
  SiteTagRelation, persistent state = new

but commitChanges() yields
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 'TAGRELATION_UNIQUE' defined on 'TAGRELATION'.


Please can someone confirm that they have the same problem... or not, which means I have to dig deeper into my code and find what I'm doing wrong.

Best regards!
Marcin
-------------------------->
ish
http://www.ish.com.au
Level 1, 30 Wilson Street Newtown 2042 Australia
phone +61 2 9550 5001   fax +61 2 9550 4001

Reply via email to