Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unidirectional Associations - Parent/Child Not Possible ?

 
Sandeep Vaid
Ranch Hand
Posts: 392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose Item - Bid as unidirectional association from Item to Bid as One-to-many. Also bid can't exists independently i.e. is must be associated with an item.

Hence
Item.java

class Item
{
Long itemId;
// Item - Bid Association (one-to-many)
Set bids = new HashSet();
}

Bid.java
class Bid
{
Long bidId;
double amount;
Bid(Long bidId, double amount)
{
.....
}
}

As Item-Bid is unidirectional, Bid class doesn't have an Item as property.
Hence we can create Bid independent of Item (using Bid(bidId,amount))...

This is incorrect scenario ....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic