Hi,
I have a problem with writing Criteria Query. To explain the problem I create a small model.
We have two entities Contract and ContractHistory.
- There is a many-to-one association defined on ContractHistory called Contract.
- On the Contract there is a bag defined called Histories.
Here the problem
I want to return an object array that contains a HistoryList and the Contract.
In hql in you can do like this
select c, ch from Contract c join c.Histories ch
The query will return a new object[]{Contract, IList<ContractHistory>}
I don't know how that I can do this with Criteria Queries. What I can do is returning individual properties of the ContractHistory and Contract using the Criteria Query.
For example:
ICriteria c = session.CreateCriteria(typeof(Contract), "c")
.SetProjection(Projections.Property("c.Name"));
This Criteria Query translate in Hql is select c.Name from Contract c join c.Histories ch
Thank for you time.