title: Hibernate Query DetachedCriteria VS bulkUpdate SQL using Collection with "in" Calause Problem
body: <p>I facing a problem on how to use SQL "in" in bulkUpdate Hibernate.</p>
  
  <p>Example :</p>
  
  <p>Country is an enum type.<br /><br />
  <b>Normal SQL statement</b></p>
  
  <pre><code>Update Persons SET country = Country.China
  WHERE country IN (Country.HK, Country.Taiwan);
  </code></pre>
  
  <p><b>Hibernate using DetachedCriteria</b></p>
  
  <pre><code>DetachedCriteria criteria= DetachedCriteria.forClass(Persons.class)
   .add(Property.forName("country").in(countryList));
  List&lt;Persons&gt; personsList = getHibernateTemplate().findByCriteria(criteria);
  
  for(Persons persons : personsList){
       person.setCountry(Country.China);
  }
  
  personsDao.updateAll(personsList);
  personsDao.flush();
  </code></pre>
  
  <p><b>Hibernate using bulkUpdate problem - Does not work!</b></p>
  
  <pre><code>getHibernateTemplate().bulkUpdate(
  "select * from Persons where country in (?)",
   new Object[] {countryList});
  </code></pre>
  
  <p><b>Error message:</b></p>
  
  <pre><code>[Lcom.model.Persons.Country; cannot be cast to java.lang.Enum]
  </code></pre>
  
  <p>But I tried this one. It works.
  [ Not using Object : I hardcode it]</p>
  
  <pre><code>getHibernateTemplate().bulkUpdate(
  "select * from Persons where country in (" + Country.HK + "," + Country.Taiwan +" )" );
  </code></pre>
  
  <p>Here the Question:<br />
  1. Can we use Object [] with "in" Clause?<br />
  2. I wonder why the system know the Object is a Country Enum.</p>
  
  <p>Example : </p>
  
  <pre><code>getHibernateTemplate().bulkUpdate(
  "select * from Persons where country = ?",
   new Object[] {country});
  </code></pre>
  
  <p>==> It working and executable.</p>
  
  <ol>
  <li>Beside Collection of Enum ( example above ), List or String [] also not working using Object with "in" Clause.</li>
  </ol>
  
  <p>Hope you guys can solve my problem.
  Thanks.
  -fsloke</p>