spring-data-jpa repository use Collection as @Param in Query
<p>I'm having an issue performing a custom query through the use of a spring data jpa repository.</p>

<p>@Query annitated method doesn't specify parametr of a List&lt;> type.</p>

<p>here are entity classes:</p>

<pre><code>@Entity
@Table(name = "\"user\"")
public class User {
  @Id
  @GeneratedValue(generator = "increment")
  private long id;

  @Column(unique = true, nullable = false)
  private String mail;

  @ManyToMany(targetEntity = Interest.class, mappedBy = "users")
  private List&lt;Interest&gt; interests = new ArrayList&lt;Interest&gt;();
  ...
  ... setters and getters.

@Entity
@Table(name = "interest")
public class Interest {
  @Id
  @Column(name = "interest_name", nullable = false, unique = true)
  private String name;

  @ManyToMany(targetEntity = User.class, fetch = FetchType.LAZY)
  private List&lt;User&gt; users = new ArrayList&lt;User&gt;();
  ...
  ... setters and getters.
</code></pre>

<p>here is query:</p>

<pre><code>@Repository
public interface UserRepository extends JpaRepository&lt;User, Long&gt; {
  @Query("select distinct u from User u where u &lt;&gt; :currentUser and
         u.interests in :currentInterests")
  List&lt;User&gt; getUsersWithSameInterests(@Param("currentUser") User user,
         @Param("currentInterests") List&lt;Interest&gt; interests);
}
</code></pre>

<p>i used this like:</p>

<pre><code>@Autowired
private UserRepository userRepository;
  @Override
  public List&lt;User&gt; getUsersWithSameInterests(User user) {
    return userRepository.getUsersWithSameInterests(user, user.getInterests());
  }
</code></pre>

<p>but got</p>

<pre><code>org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet
.
.
.
Caused by: java.sql.SQLException: No value specified for parameter 2
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:957)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:896)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:885)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:860)
at com.mysql.jdbc.PreparedStatement.checkAllParametersSet(PreparedStatement.java:2205)
at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2185)
at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2115)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1936)
at org.apache.commons.dbcp2.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:83)
at org.apache.commons.dbcp2.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:83)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:70)
... 73 more
</code></pre>

<p>No value specified for parameter 2, although 2nd parametr has valid value</p>