Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can not remove a EJB 3 entity and the error is: violation of foreign key constraint

 
raminaa niilian
Ranch Hand
Posts: 551
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am trying to write a code to remove a entity which has collection of other entitiies as one to many relation. My source code for the one to many and many to one relations are like:


In Contract class which which has a collection of Branches.





In Branch class which has a collection of BranchMemberItem





In BranchMemberItem class:


I think I have all correct codes in place and sped long time finding what is wrong but I am still getting this error. If you know what is wrong wit my code, please let me know.


 
raminaa niilian
Ranch Hand
Posts: 551
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Any comment on this?

Thanks.
 
James Sutherland
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is odd, I would expect it to delete BranchMemberItem first. Perhaps include the SQL trace.
Do you have any other relationships/foreign keys or cycles?

TopLink Essentials did have some issue with delete of OneToMany's that used a join table, but you seem to be using a foreign key so should be ok.
You may be able to remove your objects in two stages using flush(), or remove the database constraint.

Most of the deletion constraint issues in TopLink Essentials were fixed in EclipseLink, so you may consider upgrading.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic