Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • 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 ...
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Joe Ess

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!