Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 1.2.1
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 you can do like this
Code:
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:
Code:
ICriteria c = session.CreateCriteria(typeof(Contract), "c")
.SetProjection(Projections.Property("c.Name"));
This Criteria Query translate in Hql is
Code:
select c.Name from Contract c join c.Histories ch
Is there no projection that you can say all properties of an entity?
Thx for your time