-->
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: Inappropriate SQl genrated from HQL
PostPosted: Tue Jan 16, 2007 7:57 am 
Newbie

Joined: Tue Sep 12, 2006 2:41 am
Posts: 5
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3.0
I have the following problem:
have three classes with many-to-many association with each other.:

[b]Mapping documents:

MessengerRNA.hbm
<set name="proteinCollection" table="MRNA_PROTEIN" lazy="true">
<cache usage="read-write" />
<key column="MRNA_ID" />
<many-to-many class="edu.wustl.geneconnect.domain.Protein" column="PROTEIN_ID" />
</set>
<set name="geneCollection" table="GENE_MRNA" lazy="true">
<cache usage="read-write" />
<key column="MRNA_ID" />
<many-to-many class="edu.wustl.geneconnect.domain.Gene" column="GENE_ID" />
</set>

Protein.hbm
<set name="messengerRNACollection" table="MRNA_PROTEIN" lazy="true">
<cache usage="read-write" />
<key column="PROTEIN_ID" />
<many-to-many class="edu.wustl.geneconnect.domain.MessengerRNA" column="MRNA_ID" />
</set>
<set name="geneCollection" table="PROTEIN_GENE" lazy="true">
<cache usage="read-write" />
<key column="PROTEIN_ID" />
<many-to-many class="edu.wustl.geneconnect.domain.Gene" column="GENE_ID" />
</set>

Gene.hbm
<set name="messengerRNACollection" table="GENE_MRNA" lazy="true">
<cache usage="read-write" />
<key column="GENE_ID" />
<many-to-many class="edu.wustl.geneconnect.domain.MessengerRNA" column="MRNA_ID" />
</set>
<set name="proteinCollection" table="PROTEIN_GENE" lazy="true">
<cache usage="read-write" />
<key column="GENE_ID" />
<many-to-many class="edu.wustl.geneconnect.domain.Protein" column="PROTEIN_ID" />
</set>

the HQL I fired is :
From edu.wustl.geneconnect.domain.Protein as xxTargetAliasxx
where xxTargetAliasxx.messengerRNACollection.id in (
select id From edu.wustl.geneconnect.domain.MessengerRNA where
geneCollection.id in (select id From edu.wustl.geneconnect.domain.Gene where unigeneClusterId = 'Hs.326035' AND ensemblGeneId = 'ENSG00000120738') AND ( refseqId = 'NM_001964' AND ensemblTranscriptId = 'ENST00000239938' ) )

The generated SQL (show_sql=true):
select * from ( select protein0_.PROTEIN_ID as PROTEIN1_, protein0_.ENSEMBL_PEPTIDE_ID as ENSEMBL2_6_, protein0_.REFSEQ_PROTEIN_ID as REFSEQ3_6_, protein0_.UNIPROTKB_ACCESSION
as UNIPROTKB4_6_, protein0_.GENEBANK_PROTEIN_ACCESSION as GENEBANK5_6_, (select 1 from dual) as formula6_,
(select 1 from dual) as formula7_, (select 1 from dual) as formula8_, (select 1 from dual) as formula9_
from PROTEIN protein0_, MRNA messengerr2_, MRNA_PROTEIN messengerr1_
where protein0_.PROTEIN_ID=messengerr1_.PROTEIN_ID and
messengerr1_.MRNA_ID=messengerr2_.MRNA_ID and
(messengerr2_.MRNA_ID in (select messengerr3_.MRNA_ID from MRNA messengerr3_ where
(messengerr3_.MRNA_ID in
(select gene4_.GENE_ID
from GENE gene4_ where gene4_.UNIGENE_CLUSTER_ID='Hs.326035' and gene4_.ENSEMBL_GENE_ID='ENSG00000120738')
)
and messengerr3_.REFSEQ_MRNA_ID='NM_001964' and messengerr3_.ENSEMBL_TRANSCRIPT_ID='ENST00000239938')) )

In generated SQL you will see that lin ktable GENE_MRNA is missing.
--messengerr3_.MRNA_ID in (select gene4_.GENE_ID---

_________________
Sachin Lale


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 23, 2007 4:17 am 
Newbie

Joined: Tue Sep 12, 2006 2:41 am
Posts: 5
Please Help!

_________________
Sachin Lale


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 05, 2007 12:07 pm 
Newbie

Joined: Thu Jul 05, 2007 12:04 pm
Posts: 4
I'm facing similar problem.... can someone help?


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.