This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes doubt in domain relationship Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "doubt in domain relationship" Watch "doubt in domain relationship" New topic
Author

doubt in domain relationship

pavi
Ranch Hand

Joined: Jan 23, 2008
Posts: 31
Hi,

i have a doubt in domain modeeling in chapter-7 of ejb in action book.

while mentioning the relationship between the domain some are bidirectional and some are unidirectional.i am confused in this.

for example seller and item has bidirectional relationship while bidder and bid has unidirectional and order also has unidirectional relationship with other domain.

on what basis the relationship is determined.please clear me this concept.


scjp
scwcd
scbcd(preparing)
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

on what basis the relationship is determined

There are two side in a relationship : a source and a target. If you declare the relationship in only one of them, it's unidirectonal. If you declare it in both sides, it's bidirectional.



Here, the relation between employees and department is only declared on the employee side, thus it is unidirectional. Department does not reference Employee. If Department was looking like the following, then the relation would be bidirectional :


[My Blog]
All roads lead to JavaRanch
pavi
Ranch Hand

Joined: Jan 23, 2008
Posts: 31
hi
thanks for your reply.i know what is uniand bidirectional relationship.
actually my doubt is that

for example both seller and item has reference to each other.Like that why cant the bid and bidder have the same but it is declared as only unidirectional.

we can say that one bidder places zero to many bids and also we can refer many bids are placed by one bidder which is bidirectional.but in the book only unidirection is mentioned and for seller and item they have given one seller sells many item and many item is sold by one seller.

please clear this doubt for me

Thanks in advance
latha
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

hy cant the bid and bidder have the same but it is declared as only unidirectional.

I'll have to look at the book tonight But I guess it's a design decision. Of course, you can make it bidirectional, nothing prevents you from doing it. The example in the book just chooses to make it unidirectional (for educational reason ?). They decided that this time we didn't need to use the relation the other way around.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Which page did you get that bidder and bid relation from ?
pavi
Ranch Hand

Joined: Jan 23, 2008
Posts: 31
hi

it is in pageno 252.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

252 ? All I see page 252 is table 8.1 and chapter 8.1.1.
nitin pai
Ranch Hand

Joined: May 30, 2006
Posts: 185
I don't have the book currently but it may be a design decision or maybe just to showcase an example of unidirectional relationship.

However it is very important to understand that unidirectional and bidirectional relationships are only present in the framework level and not at the DB level where only one type of relationship exists and that is undirectional (by foreign key).



pavi
Ranch Hand

Joined: Jan 23, 2008
Posts: 31
hi
i am referring to the page in the pdf document.that is it is in chapter 7-7.1.2
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Mmh... Anyway, this is just a decision/educational decision. If you want to make the relationship bidirectional, you can try it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: doubt in domain relationship
 
Similar Threads
Persistence Example
JPQL doubt
EJB Relation Question
Unidirectional & Bi directional
The word inverse in a Bidirectional Relationships