-->
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: HQL outer join without relationship in mapping files
PostPosted: Fri Mar 17, 2006 9:27 am 
Newbie

Joined: Mon Feb 27, 2006 5:22 am
Posts: 2
Location: Italy
Hibernate version:
3.1.2

Hi,
I need to know if it's possible to write an HQL outer join for two tables for which there is no many-to-one relationship defined in mapping files.

Eg
Table CUSTOMERS
ID Long
NAME String
ADDRESS String
COUNTRY String ("IT", "US", "CA", "UK" etc.) <== Not defined as Country object

Table COUNTRIES
COUNTRY String (e.g. "IT", "US", "CA", "UK", etc.)
DESCRITPION String

I need to get all customers, and for each customer the description of the country (if CUSTOMER.COUNTRY field is not null)

In SQL the statement is:
SELECT CUSTOMERS.*, COUNTRIES.* FROM CUSTOMERS LEFT OUTER JOIN COUNTRIES ON CUSTOMERS.COUNTRY=COUNTRIES.COUNTRY

What's the corresponding in HQL considered that there is no hibernate relationship between these two tables?

Thanks in advance,
Davide.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 17, 2006 4:48 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
HQL does not support joining objects if relationships are not defined in the mappings.

Native SQL support should help you
http://www.hibernate.org/hib_docs/v3/re ... rysql.html

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


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.