title: java.util.ArrayList cannot be cast to java.lang.Long hibernate detached criteria
body: <p>I have a Hibernate <code>DetachedCriteria</code> Code here. I receive a <code>java.util.ArrayList cannot be cast to java.lang.Long</code> when I run the application! basically what I do here is there are two lists each with hotels and tax. the logic here is if the hotels and tax is specified, load the necessary data! if they are not load everything! when I keep hotels unselected and tax selected I receive the above error. If I select hotels and leave tax empty I get the result as expected.</p>
  
  <pre class="lang-java prettyprint-override"><code>//Use if hotel is specified
      if(searchCriteria.getHotel().getId() != null){
          dc.add(Restrictions.eq("h.id", searchCriteria.getHotel().getId()));
      }else if(hotels != null &amp;&amp; !hotels.isEmpty()){
          Collection&lt;Long&gt; hotelIds = new ArrayList&lt;Long&gt;();
          for(Hotel h : hotels){
              hotelIds.add(h.getId());
          }
          dc.add(Restrictions.eq("h.id",hotelIds));
      }
  
      //use if tax is specified
      if(searchCriteria.getTax().getId() != null){
          dc.add(Restrictions.eq("t.id", searchCriteria.getTax().getId()));
      }else if(tax != null &amp;&amp; !tax.isEmpty()){
          Collection&lt;Long&gt; taxIds = new ArrayList&lt;Long&gt;();
          for(Tax t : tax){
              taxIds.add(t.getId());
          }
          dc.add(Restrictions.eq("t.id",taxIds));
      }
  
      //Order Result
      dc.addOrder(Order.asc("h.id"));
      dc.addOrder(Order.asc("t.code"));
  </code></pre>
  
  <p>please let me know what mistake I am doing here! </p>