How to find a multiple object (composition) by parent Id

Dear all,
Sorry in advance, this is probably a very stupid question but I am really stuck on this since the last week…

My BDM contains 2 business objects: “CustomerOrder” & “orderItem”.
“CustomerOrder” includes a multiple attribute type “orderItem” (composition) which is the child object to input the items ordered.

I can’t succeed to write the customer query in the BDM definition that would find the list of items based on the parent id (the customer order id)… In the studio h2 database, the column name is “CUSTOMERORDER_PID” for this parent Id.

I have tried:
“SELECT o
FROM orderItem o
WHERE o.customerOrder_pId = :customerOrder_pId
ORDER BY o.persistenceId ASC”
But always get the message that the BDM is not managed by the BDM definition, and logs indicates that the issue comes from this quesry precisely.

Thus, I know the problem comes from the customerOrder_pId parameter but I can’t figure out why. I have tried all possible letter case for this parameter. I first thought it was because customerOrder_pId could not be found as this is automatically generated in h2 database and not int he BDM definition. But query using “persistenceId” parameter are working perfectly, so why I can’t do it similarly with customerOrder_pId? How should I write this parameter?

In advance, thanks very much for your help.

I create an example that I think is a close match to yours: an “Invoice” object with an attribute “lines” that use the type “InvoiceLine” with the option “multiple” checked and the relation set to “Composition”.

So from the data perspective (i.e. the Java classes generated when you create a BDM definition) it’s the Invoice that reference InvoiceLine. But in the database it’s actually InvoiceLine that have a reference to the Invoice (column named “INVOICE_PID”).

JPQL queries are created based on the data objects . So in order to retrieve the list of InvoiceLine that belong to an Invoice you first need to load the Invoice.
On the Invoice object you have a query available by default named findByPersistenceId that will returns the Invoice and associated InvoiceLine. Does that work for you or do you want to only get the InvoiceLine information without Invoice information?

Hi all, I succeed to make it work using a API Extension variable as follows:
…/API/bdm/businessData/ats.model.DistributionOrder/{{request.persistenceId}}/orderItems
This API request get the content of orderItems Report.

Note: following antoine.mottier’s example that probably would be:
…/API/bdm/businessData/company.com.model.Invoice/{{request.persistenceId}}/invoiceLines

FYI, useful documentation to manipulate multiple object can be found in the documentation Bonita 7.8 > Howtos > Manage multiple references in Business Objects:
https://documentation.bonitasoft.com/bonita/7.8/bo-multiple-refs-tutorial

Thank your for your help. Hope this will help others in future cases.
See you!

Hi Antoine, thanks so much for your answer. Your example is indeed close to what I wish to achieve. I will try to explain precisely following your example:

In my first process step, a user can submit/request an invoice using a form (submitInvoice). Into this form the user input some Invoice info (customer, date, etc.) and then fills a multiple object called InvoiceLine (still with your example) where he inputs reference, description, qty and price of each invoiced items.
Now, the second step is the invoice review step, this time the user’s manager is requested to complete the reviewInvoice form. In this form, he should get the Invoice information AND the InvoiceLine list.

What I cannot achieve is to have a TABLE widget which display all the InvoiceLine items of the current active Invoice, I can’t write the variable correctly I guess…

This is where I am now:
For the review form, I have the following variables (mostly inspired from the Bonita Get Started tutorial)
Variable 1: request (external API): …/{{context.invoice_ref.link}}
Following your first answer I have created:
Variable 2: currentItemList (external API): …/API/bdm/businessData/ats.model.Invoice?q=findByPersistenceId&p=0&c=10&f=persistenceId={{request.persistenceId}}

This isn’t working, when I create the table I can’t get any data, whether I am using the first or second variable. I am not sure this concept will work anyway…

To make it simple, pursuing with your example above, I wish that in the review form the manager gets the InvoiceLine details of the current Invoice under review, in a table widget for example. How would you do that?

Hope I am clear… please let me know if you need additional info.
Thanks a lot in advance. Tim