-->
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.  [ 1 post ] 
Author Message
 Post subject: Incorrect SQL generated
PostPosted: Fri Dec 21, 2007 2:34 am 
Newbie

Joined: Tue Sep 12, 2006 2:41 am
Posts: 5
Hi,
I am facing the problem where for given HQL, incorrect SQL is generated.

An association betwwen classes is as follows:
1 . Participant has one-to-many ParticiapantMedicalIdentifier (UniDirection)
2. ParticiapantMedicalIdentifier has many-to-one Site. (UniDirection)


Hibernate version:3.0

[b]Mapping documents:



Code between sessionFactory.openSession() and session.close():

String hql1 = "From edu.wustl.catissuecore.domain.Participant as xxTargetAliasxx where xxTargetAliasxx.participantMedicalIdentifierCollection.id in (select id From edu.wustl.catissuecore.domain.ParticipantMedicalIdentifier where site.id in (select id From edu.wustl.catissuecore.domain.Site where name = 'Walt'))";

Full stack trace of any exception that occurs:

Name and version of the database you are using:
MYSQL 4.0.19

[b]The generated SQL (show_sql=true):


select participan0_.IDENTIFIER as IDENTIFIER, participan0_.LAST_NAME as LAST2_13_, participan0_.FIRST_NAME as FIRST3_13_, participan0_.MIDDLE_NAME as MIDDLE4_13_, participan0_.BIRTH_DATE as BIRTH5_13_, participan0_.GENDER as GENDER13_, participan0_.GENOTYPE as GENOTYPE13_, participan0_.ETHNICITY as ETHNICITY13_, participan0_.SOCIAL_SECURITY_NUMBER as SOCIAL9_13_, participan0_.ACTIVITY_STATUS as ACTIVITY10_13_, participan0_.DEATH_DATE as DEATH11_13_, participan0_.VITAL_STATUS as VITAL12_13_ from CATISSUE_PARTICIPANT participan0_, CATISSUE_PART_MEDICAL_ID participan1_ where participan0_.IDENTIFIER=participan1_.PARTICIPANT_ID and (participan1_.IDENTIFIER in (select participan2_.IDENTIFIER from CATISSUE_PART_MEDICAL_ID participan2_ where
participan2_.IDENTIFIER in (select site3_.IDENTIFIER from CATISSUE_SITE site3_ where site3_.NAME='Walt')))


Debug level Hibernate log excerpt:


When i execute the above HQL the SQL generated is incorrect. In above SQL you will see (last two lines) participan2_.IDENTIFIER is search in Site.IDENTIFIER where it should be participan2_.SITE_ID in (select site3_.IDENTIFIER from CATISSUE_SITE site3_ where site3_.NAME='Walt')))

Is the HQL i am executing not correct? Do anyone have confronted with such issue. Please help

_________________
Sachin Lale


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.