title: Specifying list parameter in HQL NOT IN clause
body: <p>I've got the following code to set a <code>List</code> parameter in a <code>NOT IN</code> clause in an HQL query</p>
  
  <pre><code>private static final String FIND_AVAILABLE_OPERATORS = "FROM Domain domain WHERE domain.type = :type AND domain.operators NOT IN (:operators)";
  
  @SuppressWarnings("unchecked")
  @Override
  public List&lt;Domain&gt; findAvailableOperators(Domain domain) {
      Query query = null;
      if (domain.getOperators().isEmpty()) {
          query = getCurrentSession().createQuery(FIND_BY_DOMAIN_TYPE); // run another query
      } else {
          query = getCurrentSession().createQuery(FIND_AVAILABLE_OPERATORS);
          query.setParameterList("operators", domain.getOperators());
      }
  
      query.setParameter("type", DomainType.OPERATOR);
      return query.list();
  }
  </code></pre>
  
  <p>but I get an <code>SQLGrammarException</code> when my <code>List</code> is not empty</p>
  
  <pre><code>org.hibernate.exception.SQLGrammarException: No value specified for parameter 2
  </code></pre>
  
  <p>Am I using the <code>setParameterList()</code> <a href="https://stackoverflow.com/questions/4828049/in-clause-in-hql-or-java-persistence-query-language">incorrectly</a>?</p>
  
  <p>The SQL executed seems to be</p>
  
  <pre><code>Hibernate: select domain0_.domain_id as domain1_2_, domain0_.country as country2_, domain0_.name as name2_, domain0_.type as type2_ from domain domain0_ cross join domain_operators operators1_, domain domain2_ where domain0_.domain_id=operators1_.parent and operators1_.child=domain2_.domain_id and (. not in  (?)) and domain0_.type=?
  </code></pre>
  
  <p>I've never seen <code>(. not in  (?))</code>.</p>
  
  <p>EDIT: My <code>Domain</code> entity</p>
  
  <pre><code>@Entity
  @Table
  public class Domain {
      @Id
      @GenericGenerator(name = "generator", strategy = "increment")
      @GeneratedValue(generator = "generator")
      @Column(name = "domain_id")
      private Long domainId;
  
      @Column(nullable = false, unique = true)
      @NotNull
      private String name;
  
      @Column(nullable = false)
      @NotNull
      @Enumerated(EnumType.STRING)
      private DomainType type;
  
      @ManyToMany(cascade = {
              CascadeType.PERSIST,
              CascadeType.MERGE
      }, fetch = FetchType.EAGER)
      @JoinTable(joinColumns = {
              @JoinColumn(name = "domain_id")
      }, inverseJoinColumns = {
              @JoinColumn(name = "code")
      })
      private Set&lt;NetworkCode&gt; networkCodes = new HashSet&lt;&gt;();
  
      @ManyToMany(fetch = FetchType.EAGER)
      @JoinTable(joinColumns = {
              @JoinColumn(name = "parent", referencedColumnName = "domain_id")
      }, inverseJoinColumns = {
              @JoinColumn(name = "child", referencedColumnName = "domain_id")
      })
      private Set&lt;Domain&gt; operators = new HashSet&lt;&gt;();
  
      @ManyToOne(optional = false, fetch = FetchType.EAGER)
      private Country country;
  
      public Domain() {}
          ... setters/getters
      }
  </code></pre>