title: Spring query with a one to many param
body: <p>I must query network elements that have some parameters similiar to the given values, for instance searching for "xampleV" will return  rows with "ExampleValue".</p>
  
  <p>This is currently working, except for the port parameter which is mapped one to many in network element.</p>
  
  <pre><code>@Entity
  public class NetworkElement {
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      public long id;
  
      /**
       * The ip address of the NetworkElement. This should be unique
       */
      public String ip;
  
      /**
       * The port or NetworkElement
       */
      public int port;
  
      /**
       * The name this node is called. This is what the user want to see on the Gui for such NetworkElement
       */
      public String name;
  
      /**
       * Timestamp of the last alarm received for this NetworkElement
       */
      public long lastEventTimestamp;
  
      /**
       * Last read index from the alarm status table
       */
      public int lastReadIndex;
  
      public long latitude;
  
      public long longitude;
  
      public String address;
  
      public String upTime;
  
  
      @OneToMany(mappedBy = "node")
      public List&lt;Port&gt; ports;
  
      @ManyToOne
      @JoinColumn(name = "type_id")
      public NetworkElementType networkElementType;
  
      public NetworkElement(String ip, String name, long lastEventTimestamp, List&lt;Port&gt; ports, NetworkElementType networkElementType) {
          this.ip = ip;
          this.name = name;
          this.lastEventTimestamp = lastEventTimestamp;
          this.ports = ports;
          this.networkElementType = networkElementType;
      }
  
  
  }
  </code></pre>
  
  <p>This is what my query looks like in NetworkElementRepository</p>
  
  <pre><code>    @Query("SELECT ne FROM NetworkElement ne WHERE " +
          "ne.ip LIKE %:ip% AND " +
          "str(ne.port) LIKE %:port% AND " +
          "lower(ne.name) LIKE concat('%', lower(:name), '%') AND " +
          "lower(ne.networkElementType.type) LIKE concat('%', lower(:type), '%') AND " +
          "lower(ne.networkElementType.vendor) LIKE concat('%', lower(:vendor), '%') AND " +
          "lower(ne.networkElementType.version) LIKE concat('%', lower(:version), '%') AND "+
          "lower(ne.networkElementType.port) LIKE concat('%', lower(:customerId), '%')")
  
  List&lt;NetworkElement&gt; search(
          @Param("ip") String ip, @Param("port") String port,
          @Param("name") String name,@Param("vendor") String vendor,
          @Param("type") String type, @Param("version") String version, @Param("customerId") String customerId);
  </code></pre>
  
  <p>This clearly isn't correct as port is not a single value but a list.</p>
  
  <p>Here's the Port class</p>
  
  <pre><code>@Entity
  public class Port {
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      public long id;
  
      @ManyToOne
      @JoinColumn(name = "node_id")
      @JsonIgnore
      public NetworkElement node;
  
      public String type;
      /**
       * Id of the rack (may be null)
       */
      public String rack;
      /**
       * Id of the frame
       */
      public String frame;
      /**
       * Id of the card slot
       */
      public String slot;
      /**
       * Serial of the port
       */
      public String portSerial;
  
      public String customerId;
  
      public long esThresholdUp;
      public long esThresholdDown;
      public long sesThresholdUp;
      public long sesThresholdDown;
  
      public PortStatus status;
  
      /**
       * Timestamp of the last event for this port
       */
      public long lastEventTimestamp;
  
      @Override
      public String toString() {
          return "Port{" +
                  "id=" + id +
                  ", node=" + node +
                  ", type='" + type + '\'' +
                  ", rack='" + rack + '\'' +
                  ", frame='" + frame + '\'' +
                  ", slot='" + slot + '\'' +
                  ", portSerial='" + portSerial + '\'' +
                  ", customerId='" + customerId + '\'' +
                  ", esThresholdUp=" + esThresholdUp +
                  ", esThresholdDown=" + esThresholdDown +
                  ", sesThresholdUp=" + sesThresholdUp +
                  ", sesThresholdDown=" + sesThresholdDown +
                  ", status='" + status + '\'' +
                  '}';
      }
  }
  </code></pre>
  
  <p>How do I query network elements that have ports with a specific customerId correctly?</p>