public class Item { private String name; private Set categories = new HashSet(); private Set bids = new HashSet(); private Bid successfulBid; ... } ---------------------------------------------------- public class Bid { ... private Item item; ... }
----------------------------------------------------- public class User { private Address shippingAddress; private Set billingDetails; .. }
----------------------------------------------------- public class Category { private String name; private Category parentCategory; private Set childCategories = new HashSet(); private Set items = new HashSet(); .. } -----------------------------------------------------
Considering Item, Bid, User, Category: The usecase requirement is as follows:
If i write a generic DAO method which will accept which all populated associations and collections of Item should be written... Based on this input (and dynamic eager fetching), i will create a dynamic HQL which will fetch only the required data.
Item getItem(String itemId, Vector criteria){ //generate dynamic HQL using this criteria elements in fetch clause }
So in: UseCase1: Vector criteria = new Vector(0,1); criteria.add("item.successfulBid"); criteria.add("item.categories.parentCategory"); Item item = getItem(criteria);
You can then use createEqualsCriteria to deal with all equals type stuff. Keep in mind I'm not 100% spot on on the criteria Building part as I usually do this once off and forget how to instantiate it. Good luck!!