title: Using IN clause in a native sql query with Hibernate 3.2.2
body: <p>In a fashion similar to the question found here: <a href="https://stackoverflow.com/questions/831990/using-in-clause-in-a-native-sql-query">Using IN clause in a native sql query</a>; I am attempting to make use of an <code>IN()</code> clause by way of a native SQL query in Hibernate. While the author in the other question was able to use JPA, I am not. In addition, I am stuck with version 3.2.2. </p>
  
  <p>It seems as though Hibernate doesn't support <code>IN()</code> natively because it is attempting to convert my list (array of long primitives) of IDs into binary form when applying the query parameters: <code>query.setParameter("publisherGroups", [1243536264532,1243536264533,1243536264535]);</code></p>
  
  <p>From Hibernate:</p>
  
  <p><code>SELECT
          sum(C2CReportedConversion) as c2CConversion,
          sum(C2CReportedRevenue) as c2CRevenue,
          sum(I2CReportedConversion) as i2CConversion,
          sum(I2CReportedRevenue) as i2CRevenue,
          sum(Clicks) as clicks,
          sum(Impressions) as impressions,
          sum(Requests) as requests,
          sum(Views) as views,
          coalesce(Name,
          DisplayName) 
      FROM
          UiTemplateReportingCache 
      JOIN
          AdUnit USING (AdUnitId) 
      WHERE
          PublisherId = ? 
          AND PublisherGroupId IN (
              ?
          ) 
          AND Date &gt;= ? 
          AND Date &lt;= ? 
      GROUP BY
          coalesce(Name,
          DisplayName)</code></p>
  
  <p>From the mysql logs: </p>
  
  <p><code>SELECT sum(C2CReportedConversion) as c2CConversion, sum(C2CReportedRevenue) as c2CRevenue, sum(I2CReportedConversion) as i2CConversion, sum(I2CReportedRevenue) as i2CRevenue, sum(Clicks) as clicks, sum(Impressions) as impressions, sum(Requests) as requests, sum(Views) as views, coalesce(Name, DisplayName) FROM UiTemplateReportingCache JOIN AdUnit USING (AdUnitId) WHERE PublisherId = 1239660230591 AND PublisherGroupId IN (_binary'��\0ur\0[Jx ��u�\0\0xp\0\0\0
                                                        \0\0!���T\0\0!���U\0\0!���W\0\0!���m\0\0!���n\0\0!���t\0\0!���{\0\0!���|\0\0!���}\0\0!���~\0\0#��\0\0$|��S') AND Date &gt;= '2011-03-17 00:00:00' AND Date &lt;= '2011-03-18 23:59:59' GROUP BY coalesce(Name, DisplayName)</code></p>
  
  <p>Notice the <code>_binary</code> part that starts the <code>IN()</code> value. What's the trick to making this work? Will the version of Hibernate I'm using even do this? If not, what alternatives do I have?</p>
  
  <p>Thanks in advance,</p>
  
  <p>Carl</p>