• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Generic Hibernate Fetching

 
Sandeep Vaid
Ranch Hand
Posts: 392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



Considering Item, Bid, User, Category:
The use case requirement is as follows:

USE CASE 1 : Require item.successfulBid, item.categories.parentCategory
USE CASE 2 : Require item.categories.childCategories
USE CASE 3 : Require item.bid , item.user.shippingAddress, item.user.billingDetails
USE CASE 4 : Require complete item (including it's associations and collections populated)

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);

UseCase2:
Vector criteria = new Vector(0,1);
criteria.add("item.categories.childCategories");
Item item = getItem(criteria);

UseCase3:
Vector criteria = new Vector(0,1);
criteria.add("item.bid");
criteria.add("item.user.shippingAddress");
criteria.add("item.user.billingDetails");
Item item = getItem(criteria);

UseCase4:
Vector criteria = new Vector(0,1);
criteria.add("*");
Item item = getItem(criteria);

Is this a good idea..? Comments please..
 
Sandeep Vaid
Ranch Hand
Posts: 392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any updates on this guys... ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic