Trying to get all articles, with unique titles (distinct(title)), that have a body of "".
List<Article> articles = (List<Article>) session.createQuery("select distinct a.title from Article a where body = :body")
.setString("body", "")
.list();
I am getting the error:
main java.lang.ClassCastException: java.lang.String cannot be cast to blah.Model.Article Exception in thread "main" java.lang.ExceptionInInitializerError
The Article table has duplicates in it, that is why I am trying to get only unique articles. It doesn't matter which once it gets, as long as the title is unique, and the body is "".
Update Could I use a subquery to get the results?