• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cascade Save Not Working

 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I have two domain classes set up in a one-to-many relationship - class A has a list of class B's. For some reason, when I add a new instance of class B to the list in class A, that instance of B is not being persisted when I save my class A. Here are my mappings:

Class A


Class B


I can save the instance of B directly and that works but, if I try to save A, even though it has a reference to B, B doesn't get saved.

As an aside, when I look at these objects through the debugger, I can verify that A does contain a reference to B in its list and that B does have a reference to A, so the bi-directional relationships appear to be set up correctly.

Any ideas on what I have wrong, here?

Thanks.
 
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
Yeah, you'll want to persist both sides of the relationship.

-Cameron McKenzie
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic