• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SCEA Part 2 class design question

 
ahmed fayed
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a many to many relation which requires additional attribute to be persisted in the join table, for example Order and Product relation with quantity attribute.

to use JPA, that join table should be implemented as entity, and the relation is broken into many to one and one to many, I saw in many threads that I have to reserve the given domain relations without a change, I heard that many people lost points because of changes in the given domain model.

Should I reserve the given model as is (how to persist quantity in this case?), or can I change the given mode without a problem?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34851
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ahmed,
I think removing things from the domain model is the problem. It is expected a class diagram is going to have more classes and relationships than a domain model.
 
ahmed fayed
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jeanne for your reply; I'm changing in the shape of existing relation in the domain model which was direct many to many but I injected the joined table in between (it's still many to many but the diagram is changed), after seeing some threads I think I'll remove it as loosing some points for not handling quantity attribute is better than loosing them all for changing in their holy domain model.

what do you think about the desing problem itself, am I right and the built in manytomany anotation in JPA can't handle this alone?
 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1101
10
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think slight change to the domain model is ok - without affecting the basic relationship...
for ex.: if class A 'has' B - I think I can change it like class A 'has' Z and class Z 'has' B...
 
ahmed fayed
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've found another way to keep the direct relation between the two domain entities by using a Map ElementCollection feature of JPA 2.0; I've tested it on the quantity attribute and found it working.
 
xin qi
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ahmed fayed wrote:I've found another way to keep the direct relation between the two domain entities by using a Map ElementCollection feature of JPA 2.0; I've tested it on the quantity attribute and found it working.



I think class diagram should be technology agnostic, it's no need to specify what technologies you are using here, just remaining the relationship many to many should be better.
 
Dawood Kh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you considered displaying the relationship via an association class? The original domain model relationship remains unchanged. Check out http://www.jguru.com/faq/view.jsp?EID=100819 for a brief overview.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic