• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ManyToMany mapping relationship table is blank (Hibernate newbie)

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all ,

iam working on an app where the association between entities is as follows . Here comment is the owner and iteration and user are the inverse tables . The requirement is -
A user can have many comments similarly a comment can be given by multiple users .
Also an iteration can have multiple comments and a single comment can belong to multiple iterations .

The code is as follows








Now the issue that iam facing is the mapping tables are empty .
Also user.getComment() yields empty set


Before i start my web app my db entity tables prepopulated with dummy values . But during run time when i debug the code user.getcomment returns empty set .

Could anyone please help me out what could be the issue .


New-Doc-1_1.jpg
[Thumbnail for New-Doc-1_1.jpg]
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First off, your design doesn't look right to me. In the case of many-to-many relationships, you usually introduce a Join Table in between so that the relationships become something like this:

Iteration (1) --> (N) Iteration-Comment (N) <-- (1) Comment
User (1) --> (N) User-Comment (N) <-- (1) Comment

The join tables have rows that contain the IDs of the entities that it joins. That is:

Iteration-Comment fields: IterationID + CommentID
User-Comment fields: UserID & CommentID
 
Junilu Lacar
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just noticed this but having a list of Iterations and a list of Users in a Comment object just doesn't look right to me.  See my previous comment for an alternative.
 
reply
    Bookmark Topic Watch Topic
  • New Topic