Java Mailing List Archive

http://www.gg3721.com/

Home » the NHibernate development list »

Re: [NHibernate-development] Question about Criteria Queries and
 Projections

Ayende Rahien

2008-06-19

Replies: Find Java Web Hosting

Author LoginPost Reply
This should go to the users mailing list.

On Thu, Jun 19, 2008 at 9:58 PM, Geoffrey Samper <geoffrey.samper@gmail.com> wrote:
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.

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Nhibernate-development mailing list
Nhibernate-development@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nhibernate-development


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Nhibernate-development mailing list
Nhibernate-development@(protected)
https://lists.sourceforge.net/lists/listinfo/nhibernate-development
©2008 gg3721.com - Jax Systems, LLC, U.S.A.