Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Bi-directional many-to-many mapping question

 
Saathvik Reddy
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could anyone please let me know
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic