This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes ManyToMany & fields of association table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "ManyToMany & fields of association table" Watch "ManyToMany & fields of association table" New topic

ManyToMany & fields of association table

Musab Al-Rawi
Ranch Hand

Joined: Aug 06, 2007
Posts: 231
I am posting my question here since I didn't get much of response in the other forum, and it is more relevant here, sorry for repeating the question:

Here is an example to explain my questions:
let's say there is entity FOLDER that has a many to many relationship with GROUP. I could do the design as follows:

Where and How can I represent INFO?
Is the following a better design (of courseDUMMY entity won't be named DUMMY!)?
Personally I want to go for the first design but I don't know how to represent INFO field.
In that case I define Folder and Group entities as follows:
In Folder

In Group

Again how to access INFO column located in folder_group table?
Some suggested that I could use two OneToMany relationships which is possible but I am trying to figure if there is a direct solution for the situation.

Your help is greatly appreciated.

Edvins Reisons
Ranch Hand

Joined: Dec 11, 2006
Posts: 364
A typical approach is to decompose the many-to-many relationship into two many-to-one. Then your Folder Group becomes an entity and can contain any number of additional mapped properties.
It is sorta covered in the JavaRanch Style Guide.
subject: ManyToMany & fields of association table
Similar Threads
How to link existing record from database table in ManyToMany Uni-directional relationship
@ManyToOne & @JoinColumn
ManyToMany: ternary Relationship
Meet-in-the-middle mapping question
ManyToMany & fields of association table