aggregate « DAO « JPA Q&A

1. Problem using nested avg(..) aggregate function in hibernate hql

I am using HQL to get data through DAO class but it throws as error stated below :

ERROR org.hibernate.hql.PARSER  - <AST>:0:0: unexpected AST node: query
Below is my Hql Query :
select ...

2. One DAO per aggregate root or one DAO per domain obj?

I have a generic DAO which I use for all domain objects that don't need any special functionality. It contains methods such as getAll, getByExample, save, delete, etc. Those more complex domain objects which need specialized querying or persistance code get their own DAOs which extend from it. It works pretty well.

3. The DAO pattern and aggregate functions

I'm using the DAO pattern in a Hibernate project, so I have a Hibernate DAO that implements the standard DAO methods: new, fetchAll, fetch(ID), save(model), update(model), delete(model). I have a model called User that's linked to many Account models. I'd like to do is keep any HQL in the DAO's themselves, but I also would like to calculate the total balance ...