• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Set entity relationships

 
Ranch Hand
Posts: 109
1
Netbeans IDE Chrome Java
  • 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: 109
1
Netbeans IDE Chrome Java
  • 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
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • 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!
 
Nothing? Or something? Like this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic