Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Object Relational Mapping
Search Coderanch
Advance search
Google search
Register / Login
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
Tim Cooke
Ron McLeod
paul wheaton
Jeanne Boyarsky
Sheriffs:
Paul Clapham
Devaka Cooray
Saloon Keepers:
Tim Holloway
Roland Mueller
Himai Minh
Bartenders:
Forum:
Object Relational Mapping
Help With Association Object Mapping
Gregg Bolinger
Ranch Hand
Posts: 15304
6
I like...
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I don't expect a solution here because I know that the information has to be out there. I just don't know what it is called. I have three objects.
User
Role
Book
I need to map some sort of UserBookRole object. Book and User is a ManyToMany. A user can have different roles for different books. For example
User A -> Book 1 -> Author User A -> Book 2 -> Editor User B -> Book 3 -> Reviewer User B -> Book 3 -> Author User B -> Book 3 -> Editor
So what is this type of association called and where can I go to learn how to create the mappings correctly?
Thanks.
Gregg Bolinger
Ranch Hand
Posts: 15304
6
I like...
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Many valued entity association. Alright, found it in my book. But would like some feedback.
@Embeddable public class BookUser { @Parent private Book book; @ManyToOne @JoinColumn(name = "user_id", nullable = false, updatable = false) private User user; @ManyToOne @JoinColumn(name = "role_id", nullable = true) private Role role; // getters and setters }
And then in my Book object I have this:
@CollectionOfElements @JoinTable(name = "book_user", joinColumns = @JoinColumn(name = "book_id")) private List<BookUser> bookUsers;
Does that look right?
Don't get me started about those stupid
light bulbs
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Class Diagram -Association & Inheritance
Lazy association
Hibernate Association
Difference between aggregation, association and composition
Hibernate Association
More...