I am using ogm with mongodb on Glassfish v4.0.1.
Code:
@Entity
@Table(name = "blog_entry")
@NamedQueries({
@NamedQuery(name = "blog_entry_list", query = "select be from BlogEntry be order by be.created"),
@NamedQuery(name = "blog_entry_count", query = "select count(be) from BlogEntry be"),
})
public class BlogEntry extends AbstractEntity {
....
}
Code:
@Stateless
public class BlogEntryDaoBean extends AbstractDaoBean<BlogEntry> implements
BlogEntryDao {
...
@Override
public Long count() {
Object result = getEntityManager().createNamedQuery("blog_entry_count").getSingleResult();
return (Long) result;
}
}
when the blog_entry_count query is exequted, the result is of BlogEntry type. I would expect it to be a number in this case. Does ogm supports aggregate functions and count() in particular in HQL? Unfortunately I have not found any notion in the documentation. Thank you.
---------------------------
hibernate-ogm 4.1.0.Beta2, mongodb driver 2.11.3