Hello,
I’m using the Multitenancy addon of JMIX and I’ve also extended the default TenantEntity (AffiliateCompanyEntity) to hold some project specific data related to tenants. I have defined a screen with a filter where users can search product objects by tenant (affiliate company) and the way the user selects tenants is through an entity lookup filter component:
<configurations>
<configuration>
<propertyFilter id="affiliateCompanyFilter" property="tenant" operation="EQUAL" caption="Search By Affiliate Company">
<entityPicker metaClass="AffiliateCompanyEntity">
<actions>
<action id="entityLookup" type="entity_lookup">
<properties>
<property name="screenId" value="mten_Tenant.browse" />
<property name="openMode" value="DIALOG" />
</properties>
</action>
</actions>
</entityPicker>
</propertyFilter>
</configuration>
</configurations>
The problem is that the tenant property on the target object is just the tenant id which is a string:
@TenantId
@Column(name = "TENANT")
private String tenant;
but the filter lookup component is of an entity type which causes this error:
Caused by: java.lang.IllegalArgumentException: You have attempted to set a value of type class c.c.c.b.entity.AffiliateCompanyEntity for parameter tenant daBRwodD with expected type of class java.lang.String from query string select e from ProductEntity e where e.tenant = :tenantdaBRwodD order by e.location.name desc.
at org.eclipse.persistence.internal.jpa.QueryImpl.setParameterInternal(QueryImpl.java:946) ~[org.eclipse.persistence.jpa-2.7.9-7-jmix.jar:na]
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.setParameter(EJBQueryImpl.java:611) ~[org.eclipse.persistence.jpa-2.7.9-7-jmix.jar:na]
What are my options? Is there a way where the user still selects the Entity from the filter entity lookup component, but before it’s sent to the query I can use some value formatter to extract only the tenant property?