-->
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.  [ 6 posts ] 
Author Message
 Post subject: problem using hql
PostPosted: Thu Feb 23, 2006 3:49 pm 
Beginner
Beginner

Joined: Sun Jan 22, 2006 8:47 pm
Posts: 31
Hi,

I have a doubt in an hql Query.I have two tables appt,pbooking in a legacy DB.

appt(appt_id -->PK)
pbooking(pbooking_id-->PK ,appt_id -->FK)

I am not clear of the realtionhip b/w these two tables..

for every pbooking_id there is a unique not-null appt_id,but for evry appt_id there is no assciated pbooking_id..

Like this sql query :

select appt_id from appt where appt_id not in (select appt_id from pbooking)

returns "22" rows..

I didnt know how to associate these 2 tables..I defined using <one-to-one>

Now in my hql Query


1)select pBooking.apptId from Pbooking pBooking
-- > the translated sql for this :(select pbooking0_.appt_id as col_0_0_ from test.dbo.pbooking pbooking0_ )

2)select appt.pBookingRef.apptId from Appt appt
-- > (the translated sql for this : select appt0_.appt_id as col_0_0_ from test.dbo.appt appt0_)

where as i thought the translated sql shuld be like :

3)-- select pbooking1_.appt_id as col_0_0_ from test.dbo.appt appt0_, test.dbo.pbooking pbooking1_
where appt0_.appt_id=patbooking1_.appt_id

See tht in "2" its not even doing join on appt and pbooking even though i have a <one-to-one> assocition and iam querying the field of pbooking

I observed tht this behaviour is only for "appt_id" which is a pk of appt and fk of pbooking.
For any other fields which belong to pbooking it is selecting frm pbooking ,but for appt_id its selecting from
appt ..

4)select appt.pBookingRef.pbookingId appt.pBookingRef.apptId from Appt appt

translated sql -- >

select
pbooking1_.pbooking_id as col_0_0_,
appt0_.appt_id as col_1_0_
from
test.dbo.appt appt0_,
test.dbo.pbooking pbooking1_
where
appt0_.appt_id=pbooking1_.appt_id




I want to get the appt_id's in pbooking not in appt.How can I do that by querying from appt only .Pls advice.

Thnx


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 23, 2006 4:28 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
go to the user forum for starters ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 23, 2006 5:15 pm 
Beginner
Beginner

Joined: Sun Jan 22, 2006 8:47 pm
Posts: 31
i couldnt find user's forums for starters in hibernate.org


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 23, 2006 10:43 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Assuming you are being serious.
The first forum in the forum list is the user forum.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 24, 2006 2:42 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
or he could go to his profile and find it in his 21 first postings....;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 24, 2006 10:21 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
:-)


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