title: Get round 2100 parameter limit in SQLServer with hibernate
body: <p>So, I'm trying to run a HQL query on hibernate and SQL server </p>
  
  <p>The query takes a list of files and a list of manifestations. Manifestations are associated with files. The aim of the query is to find all files from a list of files which are linked to manifestations that are <em>not</em> on a list of manifestations. The query looks like this:</p>
  
  <pre><code>SELECT file.fileref from com.project.FileImpl f, com.project.ManifestationFileImpl mf 
  WHERE f.fileref IN filerefs 
  AND mf.manifestionRef NOT IN manifestationRefs 
  AND f.fileRef= mf.fileRef
  </code></pre>
  
  <p>Where fileRefs and manifestationRefs are both arrays of strings. Unfortunately, when large arrays are passed into this query, it fails because SQL server cannot accept more than 2100 parameters.</p>
  
  <p>Much as I'd like to, this is legacy code which I cannot recode to eliminate the possibility that very large arrays will be passed in. </p>
  
  <p>Is there a way (other than just breaking it down into many smaller queries and iterating though the results) to rewrite this query so that the parameter limit does not occur? </p>