Win a copy of Classic Computer Science Problems in Swift this week in the iOS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

many to many problem  RSS feed

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey ppl, I'm new to hibernate and I'm working on this erd with many to many relatio

Table 'user':

* id: integer

username: varchar

table 'user_info':

* user_id: integer (pk,fk: ref:table 'user' column:'id')

* info_id: integer (pk,fk:ref:table 'info' column:'id')

info_value: text

table 'info':

* id: integer


it's simple many to many relation between user and info tables with the join table user_info that have a third column that contains a requried value holded for the intersection between user and information.

I've made a bean for that table and in the mapping for tables user and info i added the composite-element tag in the set collection and inverse attribute in each of them and now i can get the value from the join table.

until now every thing is great but first problem i have is i must use a map collection so i can get the value with it's key that will be the name of the info in the 'info' table but i couldnt put the key of the map from that table

second problem i got is that i can only retrieve data from that column (third column) which is a very important, actually it's the purpose of the system depends on the storing and retrieving values from this column

so please can any one help me out in this ,how to map these tables and how can i populate and retrieve values from them

or just tell me about a good book that explain like this problem in full details, I've read hibernate quickly and hibernate in action but i couldn't find a proper solution for this problem

It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!