Hi all,
I'm writing (what I think should be) a simple query, to select a number of items, as well as a boolean value of whether they occur in a collection.
I have two classes, User, and NewsItem, where User contains a many-to-many collection called readItems. I wrote the following HQL query:
select n, (n in elements(u.readItems)) from NewsItem n, User u where u.id=:id
I was expecting the result to be a List of Object[], but instead I get a list of NewsItems, so I get a ClassCastException. From this, and the generated SQL, it seems that it is not selecting the read/unread status, as desired.
I am quite new to Hibernate, so can anyone tell me how I can achieve this effect?
Thanks,
Nick
|