• 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

many-to-many where middle table has extra fields

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

What kind of mapping will we have if we have additional fields in middle table, other than the foreign keys connecting the 2 tables?

Existing:

Student(key:studentid, column:name)
Student_courses (foreign keys studentid and courseid) <---middle table
Courses(key:courseid, column:description)

New:

Student(key:studentid, column:name)
Student_courses (foreign keys studentid and courseid, ADDITIONAL FIELDS: 2 NON-KEY FIELDS: STARTDATE AND ENDDATE) <---middle table
Courses(key:courseid, column:description)

As seen above, i added startdate and enddate, 2 strings.

Existing hibernate will be like this:



and



Will you let me know how the new one will be?

 
Bartender
Posts: 4568
9
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In that case you'd have an entity representing the middle table, and you'd break it down into two many-to-one relationships.
 
Jesus Angeles
Ranch Hand
Posts: 2108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks ill try that
 
reply
    Bookmark Topic Watch Topic
  • New Topic