I have the following HQL statement:
select distinct t from TaskEntity as
inner join fetch t.Case as c
inner join fetch c.Client as client
inner join fetch
Be aware that you must also provide a correct GetHashCode implementation.
Your Equals implementation is also not great.
Furthermore, both methods should return 'static' values. I have not seen your class but is should be something like:
public class TaskEntity
{
public int AccountNumber { get; protected set; }
public int CaseNumber { get; protected set; }
public Client Client { get; set; }
public Matter Matter { get; set; }
public TaskEntity(int accountNr, caseNr)
{
AccountNumber = accountNr;
CaseNumber = caseNr;
}
protected TaskEntity() {} // Needed for NHibernate proxies
}
I really recommend that you put your component id's in seperate classes when possible.
Furthermore, read the following article about override Equal as your current implementation is probably flawed : http://msdn.microsoft.com/en-us/library/bsc2ak47.aspx especially understand the part regarding inheritance and base types.