• 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
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

many to many problem  RSS feed

 
Greenhorn
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

info:varchar
------------------------------------------------------------------

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

thanks
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!