Skip to content
This repository has been archived by the owner on Mar 31, 2022. It is now read-only.

TagField does not work correctly if Entity has field with Set type #610

Closed
Flaurite opened this issue Jul 29, 2021 · 0 comments
Closed

TagField does not work correctly if Entity has field with Set type #610

Flaurite opened this issue Jul 29, 2021 · 0 comments
Assignees
Labels
type: bug Something isn't working
Milestone

Comments

@Flaurite
Copy link
Contributor

Description

  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>
  1. 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]

QA

  1. Create two entities with one-to-many association;
  2. Use Set collection type;
  3. Add TagField to the editor and try to select some values, for instance:
<tagField id="orderLinesField" property="orderLines">
    <query entityClass="com.company.app.entity.OrderLine"
           escapeValueForLike="true"
           searchStringFormat="%${searchString}%">
        <![CDATA[select e from OrderLine e where e.name like :searchString escape '\']]>
    </query>
</tagField>
  1. Save entity - there is no exception should occur.
  2. Try to use #setTagComparator. No exception should occur.

Another case try to change collection type to List and try to edit entity's collection field. No exception should occur.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants