title: JPA container OR filter - Vaadin application
body: <p>I have a vaadin7 applicaiton and a JPA Container for an Entity class. I have ListSelect control that I use to filter that container</p>
  <pre class="lang-java prettyprint-override"><code>private ListSelect generateBrokerSelects() {
          ListSelect broker_ListSelect = new ListSelect(&quot;Broker:&quot;);
          JPAContainer&lt;ReservationsBroker&gt; containerBroker = JPAContainerFactory.makeReadOnly(ReservationsBroker.class, em);
  
          containerBroker.sort(new Object[]{&quot;name&quot;}, new boolean[]{true});
  
          broker_ListSelect.setContainerDataSource(containerBroker);
          broker_ListSelect.setMultiSelect(true);
          broker_ListSelect.setRows(4);
          broker_ListSelect.setItemCaptionPropertyId(&quot;name&quot;);
  
          return broker_ListSelect;
      }
  </code></pre>
  <p>I want to filter the JPA container based on the values selected on this ListSelect control.</p>
  <pre class="lang-java prettyprint-override"><code>public List&lt;Container.Filter&gt; getFilters() {
          List&lt;Container.Filter&gt; filters = new LinkedList&lt;&gt;();
          Container.Filter filter;
  
          Set brokerList = (Set) broker_ListSelect.getValue();
          if (brokerList.size() &gt; 0) {
              for (Object brokerId : brokerList) {
                  filter = new Compare.Equal(&quot;brokerId.id&quot;, brokerId);
                  filters.add(filter);
              }
  
          return filters;
  }
  </code></pre>
  <pre class="lang-java prettyprint-override"><code>private void applyFilters() {
          container.removeAllContainerFilters();
  
          for (Container.Filter filter : getFilters()) {
              container.addContainerFilter(filter);
          }
  }
  </code></pre>
  <p>The problem with the code above is that it's effectively adding &quot;AND&quot; filters to the container so I'm only left with the last value from the ListSelect control.<br />
  What I need is to create an OR filter that contains a Compare.Equal for every selected value</p>
  <pre class="lang-java prettyprint-override"><code>new Or(new Compare.Equal(&quot;brokerId.id&quot;, id1),new Compare.Equal(&quot;brokerId.id&quot;, id2),...)
  </code></pre>
  <p>Is there a way to create an Or filter and add to that filter when I iterate the selected values of my ListSelect control?</p>