• 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

CMR Design question

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm new to container managed relationships and have hit a roadblock with my design of my "test" application. In a nutshell, I'm writing a simple application that allows Users to rate Movies. Many Users can rate many Movies, and many Movies can be rated by many Users. I have an entity bean for Users (id, name, email) and one for Movies (id, name, desc).
My thinking is that I don't need to create another entity bean for the Rating. I want to create a session bean that has an addRating() method. Is the relationship between the User and Movie entity beans enough? I simply want to connect those two beans by their id's and include a "rating" value as well.
Hope this makes some sense.
Thanks for any help in advance.
 
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, in UML terms, we would say that Rating can be designed as an association class. However, in EJB we don't really have association classes. You can model them with an interposing class, which imitates the actual association.
Movies<->MovieRating<->User
The eventual question you would come across if you only had Movie and User as classes in your application is: if more than one movie can be rated, I obviously can't store the rating in the movie, if a user can rate more than one movie, I can't store it in the user. Ya gotta store it somewhere else. (Thus the association class).
In the end, if properly designed, you would be able to do something like this:

And there you have it. (I have no idea if this will compile.) This should be pretty close to what you are thinking in your head.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic