jmix-projects / jmix-ui

DEPRECATED. Use https://github.com/jmix-framework/jmix
https://www.jmix.io
3 stars 7 forks source link

TagField does not work correctly if Entity has field with Set type (port to 1.0) #609

Closed Flaurite closed 3 years ago

Flaurite commented 3 years ago

Description

See https://github.com/Haulmont/jmix-ui/issues/610

  1. Create entities with association one to many. Select Set type for collection field.
  2. Add TagField to the editor, for instance:
    <tagField id="tagPicker"
          dataContainer="veterinarianDc"
          property="specialties">
       <query entityClass="io.jmix.petclinic.entity.veterinarian.Specialty"
                    escapeValueForLike="true"
                    searchStringFormat="%${searchString}%">
              <![CDATA[select e from petclinic_Specialty e where lower(e.name) like lower(:searchString) escape '\']]>
       </query>
    </tagField>
  3. Add some values to the TagField and try to save entity.

AR

Caused by: java.lang.ClassCastException: class java.util.ArrayList cannot be cast to class java.util.Set (java.util.ArrayList and java.util.Set are in module java.base of loader 'bootstrap')
    at io.jmix.core.metamodel.model.utils.MethodsCache$SettersHolder.accept(MethodsCache.java:188) ~[jmix-core-1.0.0.jar:na]
    at io.jmix.core.entity.BaseEntityEntry.setAttributeValue(BaseEntityEntry.java:104) ~[jmix-core-1.0.0.jar:na]
    at io.jmix.core.entity.EntityValues.setValue(EntityValues.java:73) ~[jmix-core-1.0.0.jar:na]
    at io.jmix.core.entity.EntityValues.setValueEx(EntityValues.java:198) ~[jmix-core-1.0.0.jar:na]
    at io.jmix.core.entity.EntityValues.setValueEx(EntityValues.java:151) ~[jmix-core-1.0.0.jar:na]
    at io.jmix.ui.component.data.value.ContainerValueSource.setValue(ContainerValueSource.java:170) ~[jmix-ui-1.0.0.jar:na]
    at io.jmix.ui.component.data.value.ValueBinder$ValueBindingImpl.setValueToSource(ValueBinder.java:316) ~[jmix-ui-1.0.0.jar:na]
    at io.jmix.ui.component.data.value.ValueBinder$ValueBindingImpl.componentValueChanged(ValueBinder.java:309) ~[jmix-ui-1.0.0.jar:na]
    at io.jmix.core.common.event.EventHub.publish(EventHub.java:170) ~[jmix-core-1.0.0.jar:na]
    at io.jmix.ui.component.impl.AbstractComponent.publish(AbstractComponent.java:85) ~[jmix-ui-1.0.0.jar:na]
    at io.jmix.ui.component.impl.AbstractValueComponent.componentValueChanged(AbstractValueComponent.java:154) ~[jmix-ui-1.0.0.jar:na]
    at io.jmix.ui.component.impl.AbstractField.lambda$attachValueChangeListener$ab1c93c8$1(AbstractField.java:145) ~[jmix-ui-1.0.0.jar:na]