Soccertrash
Soccertrash

Reputation: 1901

Migration issue - Kodo/OpenJPA to EclipseLink

I have an environment setup with Java EE (weblogic 10.0). Thus, Kodo/OpenJPA is used as the JPA implementation. For some reasons I want to migrate to EclipseLink. Now I have the following issue:

  1. Entity A -- ManyToMany -- Entity B
  2. FetchType.Lazy, Cascade{}
  3. JoinTable AxB
  4. ForeignKey Constraint AxB.FK_COL -> A.PK

If I want to remove the Entity A, the entry in the join column should also be deleted

Kodo/OpenJPA -> Deletion successful, SQL Trace shows, that first the AxB rows are deleted

EclipseLink -> Deletion fails, Foreign Key Constraint violation. EL tries to delete Entity A first.

This is all in one transaction (RESOURCE_LOCAL). My thought was, that if something is within a transaction, foreign key constraints may be violated? Can the order of the deletions be changed in a way that first the Join Table rows are deleted?

I use EclipseLink 1.1.4

Thanks for your help, Soccertrash

Upvotes: 1

Views: 507

Answers (1)

James
James

Reputation: 18379

This issue was fixed in later versions of EclipseLink. Try 2.0, or the latest 2.3.

Otherwise remove the target object from the collection first and call flush.

Upvotes: 1

Related Questions