title: Cannot be cast to java.io.Serializable
body: <p>I am currently using criteria to retrieve the details of a user, but when trying to query the details object with the right user, I get a ClassCastException. </p>
  
  <p>My Criteria Code;</p>
  
  <pre><code>Criteria criteria = sess.createCriteria(UserDetails.class)
  criteria.add(Restrictions.eq("user.id", user.id));
  </code></pre>
  
  <p>I also tried using;</p>
  
  <pre><code>Criteria criteria = sess.createCriteria(UserDetails.class)
  
  Criteria subCriteria = criteria.createCriteria("user");
  subCriteria.add(Restrictions.eq("id", user.id));
  </code></pre>
  
  <p>Both give me the ClassCastException. I know I can easily solve it by letting the User implement Serializable, but is there any other solution?</p>