Cannot be cast to java.io.Serializable

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.

My Criteria Code;

Criteria criteria = sess.createCriteria(UserDetails.class)
criteria.add(Restrictions.eq("user.id", user.id));

I also tried using;

Criteria criteria = sess.createCriteria(UserDetails.class)

Criteria subCriteria = criteria.createCriteria("user");
subCriteria.add(Restrictions.eq("id", user.id));

Both give me the ClassCastException. I know I can easily solve it by letting the User implement Serializable, but is there any other solution?

17
задан Thys 24 December 2010 в 08:45
поделиться