jmix-framework / jmix

Jmix framework
https://www.jmix.io
Apache License 2.0
692 stars 124 forks source link

AbstractComponentGenerationStrategy.createDatatypeField doesn't create field if a custom datatype is represented with custom class #3120

Closed glebfox closed 6 months ago

glebfox commented 7 months ago

Environment

Jmix version: 2.2.1

Bug Description

AbstractComponentGenerationStrategy.createDatatypeField doesn't create field if a custom datatype is represented with custom class.

Steps To Reproduce

  1. Create either a generic filter condition for the spentTime attribute (Time Entries view)
  2. Try to filter

Current Behavior

java.lang.IllegalArgumentException: You have attempted to set a value of type class java.lang.String for parameter spentTimeKAGfBXKn with expected type of class com.glebfox.timesheets.datatype.SpentTime from query string select e from ts_TimeEntry e where (e.user.username = :current_user_username) and (e.spentTime = :spentTimeKAGfBXKn).
    at org.eclipse.persistence.internal.jpa.QueryImpl.setParameterInternal(QueryImpl.java:941)
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.setParameter(EJBQueryImpl.java:586)
    at io.jmix.eclipselink.impl.JmixEclipseLinkQuery$Param.apply(JmixEclipseLinkQuery.java:942)
    at io.jmix.eclipselink.impl.JmixEclipseLinkQuery.getQuery(JmixEclipseLinkQuery.java:490)
    at io.jmix.eclipselink.impl.JmixEclipseLinkQuery.getResultList(JmixEclipseLinkQuery.java:135)
    at io.jmix.eclipselink.impl.JpaDataStore.executeQuery(JpaDataStore.java:601)
    at io.jmix.eclipselink.impl.JpaDataStore.loadAll(JpaDataStore.java:169)
    at io.jmix.core.datastore.AbstractDataStore.loadList(AbstractDataStore.java:129)
    at io.jmix.core.impl.UnconstrainedDataManagerImpl.loadList(UnconstrainedDataManagerImpl.java:112)
    at io.jmix.flowui.model.impl.CollectionLoaderImpl._load(CollectionLoaderImpl.java:120)

Expected Behavior

A datatype is set for the generated field and no exception is thrown

Sample Project

timesheets.zip

glebfox commented 7 months ago

For QA: test with urlQueryParameters.genericFilter disabled, because of another problem: https://github.com/jmix-framework/jmix/issues/3147

SergeiAksenov2 commented 6 months ago

Tested on Java: 1) Jmix version: 2.2.999-SNAPSHOT Jmix Studio plugin version: 2.2.SNAPSHOT6334-241 IntelliJ version: IntelliJ IDEA 2024.1 (Community Edition) 2) Jmix version: 2.2.999-SNAPSHOT Jmix Studio plugin version: 2.2.SNAPSHOT6335-233 IntelliJ version: IntelliJ IDEA 2023.3.6 (Community Edition)

There is no exception as in ticket description.