Re: Hi To retrieve Child Entity Details From Parent Entity

Posted by Paul Foxworthy on
URL: http://ofbiz.116.s1.nabble.com/Hi-To-retrieve-Child-Entity-Details-From-Parent-Entity-tp3915491p3920820.html

Hi Reddy,

You want just "Product" not "primaryProducts". getRelated expects the name of the related entity. One way of finding related entities is to look in the Web Tools. For example, see

https://demo-trunk.ofbiz.apache.org/webtools/control/ViewRelations?entityName=ProductCategory

(or the equivalent in your own deployment of Ofbiz) for the exact names of the entities related to ProductCategory.

Cheers

Paul Foxworthy

reddyraja86 wrote
Hi All,
I am new to ofbiz ,I have a requirement where i am retrieving Products and product categories , i have product category id.I can get the ProductCategory details but i am not able to retrieve the Product details.(Productcategory and Product are two entities they have one to many relation)

My Code is

GenericDelegator delegator = (GenericDelegator) DelegatorFactory.getDelegator("default");
GenericValue  agreementItems=delegator.findByPrimaryKeyCache("ProductCategory", UtilMisc.toMap("productCategoryId", request.getParameter("id")));
System.out.println( agreementItems.getString("categoryName"));

But i am not able to get the product details

List l=(List)agreementItems.getRelatedCache("primaryProducts");

can anyone help me.
--
Coherent Software Australia Pty Ltd
http://www.coherentsoftware.com.au/

Bonsai ERP, the all-inclusive ERP system
http://www.bonsaierp.com.au/