• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Set entity relationships

 
Vasilis Souvatzis
Ranch Hand
Posts: 81
1
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good evening everyone. It seems I hadn't understood the entity relationships well enough, and it breaks my program's functionality. Let me give you some quick info.

Users can register and buy courses. User entities and Course entities are Many-To-Many bidirectional with a Join table like so:



I thought that by simply doing a merge on the Course entity after I set the User, it would suffice. Clearly that's not the case and the changes aren't persisted in the database. I'm doing:



So what am I doing wrong?
 
Vasilis Souvatzis
Ranch Hand
Posts: 81
1
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
FOUND IT!

I should have merged on the User entity, the one that has the @JoinTable. Now it works correctly
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Glad to hear you were able to solve your issue! And thanks for coming back to share your solution. Unfortunately not everyone has the courtesy to do this, so have a cow for doing this!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic