aspose file tools*
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes SCEA Part 2 class design question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "SCEA Part 2 class design question" Watch "SCEA Part 2 class design question" New topic
Author

SCEA Part 2 class design question

ahmed fayed
Greenhorn

Joined: Aug 28, 2010
Posts: 9
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?

Ahmed Fayed
System Architect
SCJP, SCWCD, SCEA 1/3
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30937
    
158

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
ahmed fayed
Greenhorn

Joined: Aug 28, 2010
Posts: 9
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

Joined: Oct 16, 2003
Posts: 1089
    
  10

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...


Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
ahmed fayed
Greenhorn

Joined: Aug 28, 2010
Posts: 9
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

Joined: Aug 26, 2010
Posts: 22
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

Joined: Aug 18, 2010
Posts: 3
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.


SCEA
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SCEA Part 2 class design question