Hi there,
I'm wondering about how to get the Criteria API to do something that seems to work fine as HQL. If this topic has been covered over ad nauseum already, I apologize.
I'm trying to restrict a Criteria.list result based off of an "in" Expression placed on the IDs of the criteria object's children. So if I have an Article object, and that article has topics, I want to restrict the results to those where an article's id's are in a certain set, i.e.:
Code:
Criteria criteria = sess.createCriteria(Article.class);
criteria.add(Expression.in("topics", topicIds))
where "topics" is a child collection of Article.
Funny thing, this works in HQL:
Code:
select Article as article from Article where article.topics in ....
however, it seems to choke in the Criteria API. It tries to use the ID of the articles themselves against the "in" list, seemingly not realizing that "Article" even has a property named "topics".
Anyone else run into this problem? Thanks, Dolan