-->
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: Trying to do a left join
PostPosted: Tue May 05, 2009 9:02 pm 
Newbie

Joined: Tue May 05, 2009 8:46 pm
Posts: 1
I am using Hibernate 3.2.5. I have two mapped classes:

MappedA
MappedB

I have an un-mapped class that aggregates the two mapped classes:

public class Container {
private MappedA a;
private MappedB b;

public Container(MappedA a, MappedB b) { ...and so on...

I can run this HQL query just fine:

"select new Container(a, b) from MappedA a, MappedB b where a.field = b.field"

I want to do a left join and it is not working:

"select new Container(a, b) from MappedA a left join MappedB b where a.field = b.field"

I get this exception:

java.lang.NullPointerException
at org.hibernate.util.ReflectHelper.getConstructor(ReflectHelper.java:172)
at org.hibernate.hql.ast.tree.ConstructorNode.resolveConstructor(ConstructorNode.java:114)
at org.hibernate.hql.ast.tree.ConstructorNode.prepare(ConstructorNode.java:88)
at org.hibernate.hql.ast.HqlSqlWalker.processConstructor(HqlSqlWalker.java:840)

I looked in the ReflectHelper.getConstructor source and the types array being passes in has a length of 2 but the second entry is null. The code is not written to handle the null. It looks like the code is not properly determining the type of "b" in my HQL statement.

Has anyone tried a query like this before? Is my syntax bad or could this be a defect in the code. I need to upgrade to the latest version of Hibernate but taking a brief look at the code, there aren't a lot of changes in this area.

Ed


Top
 Profile  
 
 Post subject: Re: Trying to do a left join
PostPosted: Wed May 06, 2009 12:17 am 
Regular
Regular

Joined: Thu Sep 06, 2007 2:22 am
Posts: 108
Location: Noida,India
As per my understanding,Hibernate has limitation that two classes, which are not associated to each other, you can perform only "Theta-style joins" (which you are doing in first query).

Left join or right join work only in case of when you class are associate


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.