This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff 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