-->
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.  [ 4 posts ] 
Author Message
 Post subject: LEFT OUTER JOIN on two fields
PostPosted: Thu Feb 08, 2007 1:57 pm 
Newbie

Joined: Fri Mar 12, 2004 11:04 am
Posts: 10
Hi all,

Hibernate version:
3.2.2

My SQL query
Code:
SELECT     a.field1, a.field2

FROM         table1 a 

LEFT OUTER JOIN table2 b

ON a.field1 = b.field1 AND a.field2 = b.field2


field1 AND field 2 in TABLE2 ARE NOT PRIMARY KEYS !!!

I don't know how to create the mapping file and the Hibernate query for this kind of query ?

Can someone help me please.
Thank you.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 22, 2007 11:49 pm 
Newbie

Joined: Thu Feb 22, 2007 11:47 pm
Posts: 11
I have the exact same problem. Any help would be much appreicated!

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 23, 2007 8:05 am 
Newbie

Joined: Fri Mar 12, 2004 11:04 am
Posts: 10
Hi there,

Have solved temporarily my problem using createSQLQuery
witch support standard query ... (check hibernate documentation)

String sql = " SELECT ... LEFT OUTER JOIN table2 ... ON ... WHERE"

SQLQuery q = getSession().createSQLQuery(sql);
q.addScalar("retva1", Hibernate.INTEGER);
q.addScalar("retval2", Hibernate.INTEGER);
q.addScalar("retdate", Hibernate.CALENDAR);

List list = q.list();

for (Iterator iter = list.iterator(); iter.hasNext();) {
Object[] element = (Object[]) iter.next();
...


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 24, 2007 12:46 am 
Newbie

Joined: Thu Feb 22, 2007 11:47 pm
Posts: 11
Thanks, I have certainly considered dropping back to SQL, was just hoping I could keep all my queries in HQL.


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