-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: NHibernate Criteria with Grouping
PostPosted: Tue Mar 30, 2010 4:26 am 
Newbie

Joined: Fri Mar 05, 2010 12:00 am
Posts: 2
SELECT t.BAmount, t.FAmount, acc.SettlementCurrencyID
FROM [dbo].[TransactionDetail] t
INNER JOIN Acquirer a ON a.ID = t.AcquirerID
INNER JOIN AcquirerCard ac ON ac.AcquirerID = a.ID and ac.CardID = t.CardID
INNER JOIN AcquirerCardCurrency acc ON acc.AcquirerCardID = ac.ID and acc.FCurrencyID = t.FCurrencyID

This is my native sql to group base on SettlementCyrrencyID.

I know how to do Criteria with Grouping. But my problem is that I dont know how to join TransactionDetail to AcquirerCardCurrency table.

How can I create NHibernate Criteria with Grouping?

Please let me know..

Thanks you so much.


Top
 Profile  
 
 Post subject: Re: NHibernate Criteria with Grouping
PostPosted: Fri Apr 02, 2010 4:45 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
If you've mapped all the associations, it would look like this:

session.CreateCriteria(typeof(TransactionDetail), "t")
.CreateAlias("t.Acquirer", "a")
.CreateAlias("a.AcquirerCard", ac)
.CreateAlias("ac.AcquirerCard", acc)
.Add(Expression.PropertyEqual("ac.CardId", "t.CardId")
.Add(Expression.PropertyEqual("acc.FCurrencyID", "t.FCurrencyID")


Remeber that you need classnames and propertynames here.

_________________
--Wolfgang


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.