-->
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.  [ 5 posts ] 
Author Message
 Post subject: HQL left outer join
PostPosted: Wed Mar 04, 2009 2:04 am 
Newbie

Joined: Tue May 13, 2008 5:22 am
Posts: 7
Hi all,

I am using Hiberanate 3 on postgres.

I have a problem in using left outer join in HQL query.

the query . in @Named Query
query="select code, detail from Code code left outer join Detail detail
on (detail.id= code.id) where code.category = :category order by code.id"


Here the object Code is not mapped to object Detail.

I came across some threads in this forum but din help.

The same query works fine when i write in sql as sql query in the database directly..

I get the error:
Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Can't resolve reference to bean 'transactionInterceptor' while setting property 'transactionInterceptor'; nested exception is org.springframework.beans.factory.BeanCreationException...................

Is there anyway to join these 2 unmapped objects?

I want to join without mapping..
Please.. If anybody can help me with this..

Thanks in advance..

Waiting desperately for a reply..


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 04, 2009 3:11 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
Quote:
Is there anyway to join these 2 unmapped objects?


No. Left joins are not possible unless you map an association between the entities.


Top
 Profile  
 
 Post subject: Any other way
PostPosted: Wed Mar 04, 2009 9:22 am 
Newbie

Joined: Tue May 13, 2008 5:22 am
Posts: 7
Thanks for the reply..

Somehow i cannot associate these two tables at this point cos it ll interfere with the existing data.

So is there any other way to write the query which does the same without using join.



Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 04, 2009 9:39 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
I guess it would be possible with an SQL query. See http://www.hibernate.org/hib_docs/v3/re ... eries.html


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 04, 2009 12:40 pm 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
Additional to nordborg's solution (if you want to stick with hql): You could do a cartesian product, so that an association is not necessary, e.g.:
Code:
...from Code code, Detail detail where (detail.id = code.id)...

Of course thats not as good as a join.

_________________
-----------------
Need advanced help? http://www.viada.eu


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