This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
This can be achieved by <many-to-one> mapping. Just that the parentProduct is the Product object itself. so the mapping for the parentProduct would
look something like
<many-to-one name="parentProduct" class="Product" column="PARENT_PRODUCT_ID" cascade="save-update"/>
To get all the child products for a parent product, you can use criteria with restrictions, which would be something like
criteria.add(Restrictions.eq("parentProduct.productId", new Integer(1)));
Here we are getting all child products for the parent product with product Id =1
Ofcourse, the book covers many-to-one mapping.
Joined: Jul 10, 2008
subject: Does book has an example on parent-child relation?