aspose file tools*
The moose likes Object Relational Mapping and the fly likes Bi-directional many-to-many mapping question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Bi-directional many-to-many mapping question" Watch "Bi-directional many-to-many mapping question" New topic
Author

Bi-directional many-to-many mapping question

Saathvik Reddy
Ranch Hand

Joined: Jun 03, 2005
Posts: 228
Hi,

I have an many-to-many relationship mapped with annotations
as below:





I am updating the UserGroup by doing:

I am getting this exception:


If i remove cascade=CascadeType.ALL from Group entity i
don't get any exception but i want to keep cascade in Group entity.
Is there anything i need to do to get rid of this exception or I should
remove cascade in Group entity?

Thanks,
Saathvik Reddy
Ranch Hand

Joined: Jun 03, 2005
Posts: 228
Could anyone please let me know
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

[UserGroup#<null>]


I think this means the primary key of the object you are trying to delete is null. Can you verify this by doing some logging? So, if the primary key is null and you ask Hibernate to delete it, it won't know what row in the underlying database to delete.

-Cameron McKenzie
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Bi-directional many-to-many mapping question
 
Similar Threads
Orphan delete doesn't seem to be working properly
detached entity passed to persist
using 2 @OnetoMany annoations in one Entity Class
JPA: Cascade delete for join tables with composite key
Outer join between 3 entities in HQL