-->
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.  [ 3 posts ] 
Author Message
 Post subject: About Distinct Query??
PostPosted: Wed Oct 18, 2006 6:23 am 
Newbie

Joined: Wed Oct 18, 2006 3:17 am
Posts: 4
Hi all,
I'm newbie on Hibenate and my problem is;

I have 2 main tables(TerminalTable,AirlineTable) and a sub table(TerminalAirlineBaseTable).
I want to use this sub table distincted with the select query as to airline.
Which criteria code should I write for resultList?


TerminalAirlineBaseTable
terminalID AirlineID
---------- ---------
1 2
1 2
1 2
2 4
2 4
2 4
. .
. .
. .
TerminalTable <... ... AirlineTable
ID Name ID Name
-- ----- -- -----
1 aaa 2 AEROXXX
2 bbb 4 AEROYYY
3 ccc 5 AEROZZZ


resultList(); : TerminalTable AirlineTable
aaa AEROXXX
bbb AEROYYY

thanks for help
jotun


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 18, 2006 6:28 am 
Newbie

Joined: Wed Oct 18, 2006 3:17 am
Posts: 4
I'm sorry about that I mean TerminalTable and AirlineTable not same table...

TerminalTable
ID Name
-- -----
1 aaa
2 bbb
3 ccc



AirlineTable
ID Name
-- -----
2 AEROXXX
4 AEROYYY
5 AEROZZZ


TerminalAirlineBaseTable
terminalID AirlineID
---------- ---------
1 2
1 2
1 2
2 4
2 4
2 4
. .
. .
. .


resultList(); :
TerminalTableAirlineTable
Name Name
------ -------
aaa AEROXXX
bbb AEROYYY

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 18, 2006 6:50 am 
Newbie

Joined: Wed Oct 18, 2006 3:17 am
Posts: 4
I solve this problem;

Session session = getCurrentSession();
Criteria criteria = session.createCriteria(FidsEventParameter.class);

criteria.setProjection(Projections.distinct(Projections.projectionList().add(Projections.property("terminal", "terminal").add(Projections.property("airline","airline"))).setResultTransformer(new AliasToBeanResultTransformer(FidsEventParameter.class));

List allparameterList = criteria.list();
return allparameterList;

thanks...
Jotun


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.