I’ve tried to migrate a project from Cuba 6 to Cuba 7 framework but after I pass through couple compilation errors (reinject LookupField etc) finally I can run it.
Unfortunatelly when I try to open an old record I have this error:
IllegalArgumentException: You have attempted to set a value of type class com.crm.entity.Invoice for parameter ds_invoiceDs with expected type of class java.util.UUID from query string
select e from crm$Transaction e
inner join e.invoice i
where i.id = :ds_invoiceDs
My xml file:
<collectionDatasource id="transactionsDs"
class="com.software.crm.entity.Transaction"
view="transaction-with-payment-inv-ord">
<query>
<![CDATA[select e from crm$Transaction e
inner join e.invoice i
where i.id = :ds$invoiceDs
]]>
</query>
</collectionDatasource>
I think I have to setParameters…but I don’t know how…
In Cuba 6 framework it works.
I think you just need to change the “i.id” to “i”? Since :ds$invoiceDs references an invoice object, you can’t compare that to an ID (UUID) object.
I am also in the process of converting from v6 to v7, but I am also changing all of my Datasource definitions to Data Containers and Data Loaders. If you had written this as a v7 Data Container (which requires a change in the XMLNS namespace parameter), it might look like this:
<data>
<collection id="transactionDc"
class="com.software.crm.entity.Transaction"
view="transaction-with-payment-inv-ord">
<loader id="transactionDl">
<query>
<![CDATA[select e from crm$Transaction e
inner join e.invoice i
where i.id = :invoiceId
]]>
</query>
</loader>
</collection>
</data>
Then in your Controller, you need:
@Inject
private CollectionLoader<Transaction> transactionDl;
@Subscribe
private void onInit(InitEvent event) {
// do something here to fill in the invoiceId you want to find transactions for
transactionDl.setParameter("invoiceId", invoiceId);
transactionDl.load();
}
This is how you set a parameter in your query string.
Note – I typed this directly into the reply here. There are probably bugs, but this is the general idea.
which has a better way of linking the data loaders. The code in that post maintains coordination by re-executing the transaction loader whenever the invoice is changed (in your case). My code does not do that.