title: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Long (Hibernate)
body: <p>I am trying to run a subquery in hibernate like this:-</p>
  
  <pre><code>DetachedCriteria cartProductIds = DetachedCriteria.forClass(UserCart.class,"usercart")
                                          .add(Restrictions.eq("is_deleted", false))
                                          .add(Property.forName("usercart.user_id").eq(Property.forName("search.userId")))
                                          .add(Property.forName("usercart.product_id").eq(Property.forName("search.productId")))
                                          .setProjection(Projections.property("product_id"));
  
  List&lt;SearchHistory&gt; history=session.createCriteria(SearchHistory.class,"search")
                                  .add(Restrictions.between("creationTime", startTime, Timings.getCurrentTime()))
                                  .add(Restrictions.eq("notification_send", false))
                                  .add(Subqueries.notIn("productId", cartProductIds))
                                  .list();
  </code></pre>
  
  <p>But there is a error on notIn subquery line which shows as :-</p>
  
  <p><code>java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Long.</code></p>
  
  <p>Need help to solve this issue.Thanks!</p>