-->
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: Problem With Inner Join
PostPosted: Fri Jun 01, 2007 6:41 am 
Regular
Regular

Joined: Mon Apr 02, 2007 3:54 am
Posts: 67
Location: Hyderabad
Hi All,

I am having two tables A and B. A is having its primary key x which is a foreign key to B. My hql is like
Select something From A a join a.somename
added mapping with A mapping file is
<many-to-one name="somename" class="B" column="x">
Pojo is having setter,getter of B class with is having name as somename.

But its generated sql is :
Select something from A a inner join B b on a.primary key of A = b.primary key of B

I want the primary key of A only in the queries left join part.


I am new to the technology. If AnyOne can resolve my problem, I will be thankful to him.

Thanks In Advance,
Gopal


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 01, 2007 12:21 pm 
Beginner
Beginner

Joined: Thu Apr 12, 2007 10:43 am
Posts: 21
Location: Brazil
Try the following HQL:

SELECT a
FROM A AS a
LEFT JOIN FETCH a.somename

Cheers,
Roger


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 02, 2007 4:16 am 
Regular
Regular

Joined: Mon Apr 02, 2007 3:54 am
Posts: 67
Location: Hyderabad
Thanks Rogger but.......

If I join a table with another table whose primary key is foreign key to first table, The same query works fine. But When I join a table to another table which is having first one's primary key as defined in my problem. The second table makes join with its primary key, not with the foreign key having itself . May be somewhere I am doing mistake in mapping. Please suggest me a way to do.


Thanks,
Gopal


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.