No problem, glad I could help.
I have an abstract DAO base class that implements the IBaseDao<T> interface found in the BLL.
Code:
public abstract class BaseNHibernateDao<T> : IBaseDao<T>
{
// The NHibernate ISession
private ISession _session;
// The object type the DAO is dealing with
private Type persitentType = typeof(T);
public T GetById(int id, bool shouldLock)
{
return Session.Load<T>(id);
}
// implementations for
// GetAll, GetByCriteria, Save, Delete, Evict, Commit, etc...
}
Then I have an interface in the BLL for each of my corresponding domain object DAOs. Like IResourceDao, IUserDao, IReviewDao, IQueueDao, whatever... Then I have a class for each of these interfaces in my DAL that inherit all of their functionality from BaseNHibernateDao<T> except for domain object specific HQL queries.
Code:
public class NHibernateQueueDao : BaseNHibernateDao<Queue>, IQueueDao
{
public IList<Queue> findAllOpenQueues()
{
IQuery query = session.getNamedQuery("findAllOpenQueues");
return query.list<Queue>();
}
public IList<Queue> findAllOpenQueuesForUser(User user)
{
IQuery query = session.getNamedQuery("findAllOpenQueuesForUser");
query.setParameter("user", user);
return query.list<Queue>();
}
// other HQL/named queries
}
[/code]