posted 14 years ago
Hi Varun,
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.
Regards
Srinivas