This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
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

Hibernate Query Criteria to output a Join Table and get specific column

 
Lucky Murari
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a table cartitems where the items added to the cart are stored in. It has columns:

id (Primary Key), sku, quantity, userId, status, size and couple of other columns

I also have a productAvailability table in which we store Inventory levels and where I have following columns:

sku, size , quantity, BatchId (Primary Key)

Also product table has one-to-many relationships with productAvailability table and cartitems table both on the sku key


Now, for each cartitems with status = 1 and userId=x we need to check the availability of the product and if available, I need the CartItems row and the BatchId of the product:

I got till here:




The above basically does following:



This way I cannot get the BatchId. I tried using JOIN FETCHTYPE but it still loads productAvailability table with all sizes of an sku. Is there any way for me to get both cartItems and corresponding BatchId for each cartItem?
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic