Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Unidirectional Associations - Parent/Child Not Possible ?  RSS feed

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.


class Item
Long itemId;
// Item - Bid Association (one-to-many)
Set bids = new HashSet();
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
Boost this thread!