Custom Filter not working in 7.0.7

Hi,

I had a custom gui filter working in Cuba Platform 7.0.6.
When I upgrade to Cuba Platform 7.0.7 then this stops working and the filter ignores my input.
The filter does not even reload the table, as it seems and just shows all entries.

<?xml version="1.0" encoding="UTF-8"?>

<filter>
  <and>
    <c name="KndKrtnNr" class="java.lang.Long" caption="msg://kndKrtnNr" width="1" type="CUSTOM" entityAlias="e"><![CDATA[kndKrtn.id = :component$filter.KndKrtnNr92228]]>
      <param name="component$filter.KndKrtnNr92228" javaClass="java.lang.Long">NULL</param>
      <join><![CDATA[left join {E}.kndKrtnList kndKrtn]]></join>
    </c>
  </and>
</filter>

If you need help with reproducing this issue, then just tell me.
I hope you can fix this in 7.0.8.

Kind regards,
J

Hi,
Thank you for reporting the issue.
It will be fixed in the next 7.0 update. See Custom filter conditions don't work · Issue #2217 · cuba-platform/cuba · GitHub

Has there been some changes in the GUI Filter in CUBA 7?

I have been using the same settings in 6.10 and 7.0.6 with legacy Screens, but now I moved to 7.0.8 with new Standard screens and get an error with the old filter settings.

I’m not sure, if this is related to the bugfix.
Can you check this please.

Thank you very much for all your help so far.

In 7.0.8 I get the following error:

java.lang.UnsupportedOperationException: Condition is not supported: null
	at com.haulmont.cuba.core.global.filter.QueryFilter.createQueryCondition(QueryFilter.java:201)
	at com.haulmont.cuba.core.global.filter.QueryFilter.createQueryCondition(QueryFilter.java:193)
	at com.haulmont.cuba.core.global.filter.QueryFilter.toQueryCondition(QueryFilter.java:144)
	at com.haulmont.cuba.gui.components.filter.FilterDelegateImpl$LoaderAdapter.refreshIfNotSuspended(FilterDelegateImpl.java:3128)
	at com.haulmont.cuba.gui.components.filter.FilterDelegateImpl.refreshDatasource(FilterDelegateImpl.java:1752)
	at com.haulmont.cuba.gui.components.filter.FilterDelegateImpl.apply(FilterDelegateImpl.java:1592)
	at com.haulmont.cuba.gui.components.filter.FilterDelegateImpl.apply(FilterDelegateImpl.java:1606)
	at com.haulmont.cuba.gui.components.filter.FilterDelegateImpl.loadFiltersAndApplyDefault(FilterDelegateImpl.java:534)
	at com.haulmont.cuba.web.gui.components.WebFilter.loadFiltersAndApplyDefault(WebFilter.java:99)
	at com.haulmont.cuba.gui.xml.layout.loaders.FilterLoader.lambda$loadComponent$1(FilterLoader.java:141)
	at com.haulmont.cuba.gui.xml.layout.loaders.ComponentLoaderContext.executePostInitTasks(ComponentLoaderContext.java:135)
	at com.haulmont.cuba.web.sys.WebScreens.createScreen(WebScreens.java:253)
	at com.haulmont.cuba.web.sys.WebScreens.create(WebScreens.java:171)
	at com.haulmont.cuba.gui.config.MenuItemCommands$ScreenCommand.run(MenuItemCommands.java:212)
	at com.haulmont.cuba.web.sys.MenuBuilder$MenuCommandExecutor.accept(MenuBuilder.java:256)
	at com.haulmont.cuba.web.sys.MenuBuilder$MenuCommandExecutor.accept(MenuBuilder.java:241)
	at com.haulmont.cuba.web.gui.components.mainwindow.WebAppMenu$MenuItemImpl.menuSelected(WebAppMenu.java:435)
	at com.vaadin.ui.MenuBar.changeVariables(MenuBar.java:225)
	at com.vaadin.server.communication.ServerRpcHandler.changeVariables(ServerRpcHandler.java:611)
	at com.vaadin.server.communication.ServerRpcHandler.handleInvocation(ServerRpcHandler.java:457)
	at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:400)
	at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:260)
	at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:82)
	at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:40)
	at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1577)
	at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:425)
	at com.haulmont.cuba.web.sys.CubaApplicationServlet.serviceAppRequest(CubaApplicationServlet.java:329)
	at com.haulmont.cuba.web.sys.CubaApplicationServlet.service(CubaApplicationServlet.java:215)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.web.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:107)
	at org.springframework.web.filter.CompositeFilter.doFilter(CompositeFilter.java:73)
	at com.haulmont.cuba.web.sys.CubaHttpFilter.doFilter(CubaHttpFilter.java:108)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:748)

Filter:

<?xml version="1.0" encoding="UTF-8"?>

<filter>
  <and>
    <and name="group" unary="true" width="1">
      <c name="status" class="de.nexloy.crm.vorgangsverwaltung.entity.Status" caption="Status" operatorType="EQUAL" width="1" type="PROPERTY"><![CDATA[e.status = :component$filter.status36796]]>
        <param name="component$filter.status36796" javaClass="de.nexloy.crm.vorgangsverwaltung.entity.Status">inArbeit</param>
      </c>
      <c name="vorgangskategorie" class="de.nexloy.crm.vorgangsverwaltung.entity.Vorgangskategorie" caption="Vorgangskategorie" operatorType="EQUAL" width="2" type="PROPERTY"><![CDATA[e.vorgangskategorie.id = :component$filter.vorgangskategorie25594]]>
        <param name="component$filter.vorgangskategorie25594" javaClass="de.nexloy.crm.vorgangsverwaltung.entity.Vorgangskategorie">NULL</param>
      </c>
      <c name="filNr" class="de.nexloy.crm.vorgangsverwaltung.entity.Fil" caption="Filiale" operatorType="EQUAL" width="3" type="PROPERTY"><![CDATA[e.filNr.id = :component$filter.filNr07295]]>
        <param name="component$filter.filNr07295" javaClass="de.nexloy.crm.vorgangsverwaltung.entity.Fil">NULL</param>
      </c>
      <c name="zxBEezfeRH" class="java.lang.String" width="3" type="CUSTOM" locCaption="Angelegt/geändert von" entityAlias="e"><![CDATA[(
 TRIM(LOWER({E}.angelegtVon)) like CONCAT('%',CONCAT(TRIM(LOWER(:component$filter.zxBEezfeRH37133)),'%'))
 OR
 TRIM(LOWER({E}.geaendertVon)) like CONCAT('%',CONCAT(TRIM(LOWER(:component$filter.zxBEezfeRH37133)),'%'))
 OR
 EXISTS (
        SELECT 1
        FROM   vorgangsverwaltung$VorgangHistorie vh
        WHERE  TRIM(LOWER(vh.createdBy)) like CONCAT('%',TRIM(LOWER(:component$filter.zxBEezfeRH37133)),'%')
        AND    {E}.id = vh.vorgang.id
 )
)]]>
        <param name="component$filter.zxBEezfeRH37133" javaClass="java.lang.String">NULL</param>
      </c>
      <c name="HotIoptbIm" class="java.lang.String" width="1" type="CUSTOM" locCaption="Suche" entityAlias="e"><![CDATA[(
    TRIM(LOWER({E}.anliegen)) like CONCAT('%',TRIM(LOWER(:component$filter.HotIoptbIm48050)),'%')
    or
    TRIM(LOWER({E}.bezug)) like CONCAT('%',TRIM(LOWER(:component$filter.HotIoptbIm48050)),'%')
    or
    TRIM(LOWER({E}.kontaktperson)) like CONCAT('%',TRIM(LOWER(:component$filter.HotIoptbIm48050)),'%')
    or
    TRIM(LOWER({E}.vorgangskategorie.hauptkategorie)) like CONCAT('%',TRIM(LOWER(:component$filter.HotIoptbIm48050)),'%')
    or
    TRIM(LOWER({E}.vorgangskategorie.unterkategorie)) like CONCAT('%',TRIM(LOWER(:component$filter.HotIoptbIm48050)),'%')
    or 
    EXISTS (
        SELECT 1
        FROM   vorgangsverwaltung$VorgangHistorie vh
        WHERE  TRIM(LOWER(vh.text)) like CONCAT('%',TRIM(LOWER(:component$filter.HotIoptbIm48050)),'%')
        AND    {E}.id = vh.vorgang.id
    )
)]]>
        <param name="component$filter.HotIoptbIm48050" javaClass="java.lang.String">NULL</param>
      </c>
      <c name="kontaktperson" class="java.lang.String" caption="Kontaktperson" operatorType="CONTAINS" width="1" type="PROPERTY"><![CDATA[e.kontaktperson like :component$filter.kontaktperson78172 ESCAPE '\' ]]>
        <param name="component$filter.kontaktperson78172" javaClass="java.lang.String">NULL</param>
      </c>
    </and>
    <and name="group" unary="true" width="1">
      <c name="adHynNhtMd" class="java.sql.Date" width="1" type="CUSTOM" locCaption="Von" entityAlias="e"><![CDATA[(
e.angelegtAm >= :component$filter.adHynNhtMd92470
or
e.geaendertAm >= :component$filter.adHynNhtMd92470
or 
    EXISTS (
        SELECT 1
        FROM   vorgangsverwaltung$VorgangHistorie vh
        WHERE  (vh.createTs >= :component$filter.adHynNhtMd92470 or vh.updateTs >=:component$filter.adHynNhtMd92470)
        AND    {E}.id = vh.vorgang.id
    )
)]]>
        <param name="component$filter.adHynNhtMd92470" javaClass="java.sql.Date">NULL</param>
      </c>
      <c name="hOAVDjHxnt" class="java.sql.Date" width="1" type="CUSTOM" locCaption="Bis" entityAlias="e"><![CDATA[(
e.angelegtAm <= :component$filter.hOAVDjHxnt96380
or
e.geaendertAm <= :component$filter.hOAVDjHxnt96380
or 
    EXISTS (
        SELECT 1
        FROM   vorgangsverwaltung$VorgangHistorie vh
        WHERE  (vh.createTs <= :component$filter.hOAVDjHxnt96380 or vh.updateTs <=:component$filter.hOAVDjHxnt96380)
        AND    {E}.id = vh.vorgang.id
    )
)]]>
        <param name="component$filter.hOAVDjHxnt96380" javaClass="java.sql.Date">NULL</param>
      </c>
    </and>
  </and>
</filter>

Can you reproduce the issue on a test project?

I narrowed it down to a single line in the custom filter.

Line:

{E}.angelegtAm >= ?

Filter:

<?xml version="1.0" encoding="UTF-8"?>
<filter>
  <and>
    <c name="HdYmatMVNy" class="java.sql.Date" width="1" type="CUSTOM" locCaption="Von" entityAlias="e"><![CDATA[{E}.angelegtAm >= :component$filter.HdYmatMVNy93114]]>
      <param name="component$filter.HdYmatMVNy93114" javaClass="java.sql.Date">NULL</param>
    </c>
  </and>
</filter>

I tried to create a test project, but with a reduced functionality, it works.
I think its a Problem with the data model, but I do not now where, because I have similar implementations working with the same kind of date field.

E.g.:

    @Temporal(TemporalType.DATE)
    @Column(name = "ANGELEGT_AM", nullable = false)
    protected Date angelegtAm;

    public Date getAngelegtAm() {
        return angelegtAm;
    }

    public void setAngelegtAm(Date angelegtAm) {
        this.angelegtAm = angelegtAm;
    }

I don’t see any problem with your filter definition or data model. Such case works for me.
You can try to debug the code in QueryFilter.createQueryCondition() step-by-step.

I don’t think there is an error in my filter.
I put everything in a raw query and mapped the parameter and it worked.

I don’t know how to debug that with data loader. I think queryfilter is for legacy datastores.
Can you give me an example how to do that on Cuba 7 with data loader.

Thank you very much in advance.


What I also saw is this:
In the second “AND” query group (with the date fields “Von” and “Bis”) are by default no values specified.
If I set only one value for the query filter in this group, then it works.
I think, that the Exception is thrown because both query parts are ignored, because of their null values, and are reduced to null.

This probably works like this:
Before:

    <and name="group" unary="true" width="1">
    <c name="HdYmatMVNy" class="java.sql.Date" width="1" type="CUSTOM" locCaption="Von" entityAlias="e"><![CDATA[{E}.angelegtAm >= :component$filter.HdYmatMVNy93114]]>
      <param name="component$filter.HdYmatMVNy93114" javaClass="java.sql.Date">NULL</param>
    </c>
    </and>

Afterwards - on runtime with null values:

    <and name="group" unary="true" width="1">
    </and>

This results in an Exception because no conditions are set in this group. The conditions are null.

My workaround:
grafik