Reputation: 629
Restrictions.in(String propertyName,Collection values) work fine if an ArrayList of String or Integer or even simple array is passed to it.However I want to pass ArrayList of DTO object where DTO has a mapping file defined in hibernate.cfg.xml.
Here is the code for it:
Criteria criteria =session.createCriteria(MyDTO.class);
criteria.add(Restrictions.in("reservationId",dtoList));
assignments=(ArrayList<MyDTO>)criteria.list();
Here dtoList is ArrayList. I am getting a ClassCastException. Why doesn't this work when the mapping for the entity is known by Hibernate.
Upvotes: 1
Views: 384