valueCollectionDatasource query with lookupField component value

Hi,

I’m migrating my application from Cuba 6.10.14 to Cuba 7.1.2 and I’ve been facing some problems with lookupField component and how to make a query with its value.

In the old version, I had a groupDataSource like this:

 <groupDatasource id="estadoDs" class=".....IcEstado">
     <query><![CDATA[select e from bo$IcEstado e ]]></query>
 </groupDatasource>

Then, my lookupField component:

<lookupField id="canalField" optionsDatasource="canalDs" caption="msg://canalField"
captionProperty="nombre"/>

And finally, I used the value of the component in order to make a filter in the query as follows:

<valueCollectionDatasource id="idDs" maxResults="31" datasourceClass="XXXX">
    <query><![CDATA[select ... from ... where tipo.id = :component$canalField ]]></query>
    <properties>XXXX</properties>
</valueCollectionDatasource>

In 6.10.14 version, it was working without problems. But when I’ve migrate to 7.1.2 version I get the following error:

You have attempted to set a value of type class IcEstado for parameter component_estadoField with expected type of class java.lang.Long from query…

Is there a way to fix it in the current version?

Thanks in advance.

Regards.

1 Like

Hi,

It’s not quite clear for me, because you’ve stripped all essential details from your query and exception stacktrace. Exception message mentions “component_estadoField”, but this component is not mentioned in code snippets.

But I can guess that you are passing component value which is entity and compare it with entity ID (Long) in a query.
E.g. :

select u from sec$User u where u.group.id = :component_group

You can try to remove “.id” and modify the query to:

select u from sec$User u where u.group = :component_group

Hi,

Yes, sorry for the mistake. In the same screen with we have another lookupField and we have the same problem. I’ve copied the wrong log. The component name is “component_canalField”.

We tried with your solution and it doesn’t work. It seems that in the older version, the lookupComponent value was the ID, but when we’ve changed to the latest version, the component doesn’t work in the same way. Could it be possible? Because we are getting the entity.

Thanks.

Regards.

What is the error message if it doesn’t work?

Could you prepare a small demo project with a couple of entities and screens where the problem is reproduced? In this case we will be able to precisely advise what changes should be made.