-->
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.  [ 5 posts ] 
Author Message
 Post subject: select query returning property
PostPosted: Mon Mar 29, 2004 7:50 am 
Newbie

Joined: Mon Mar 29, 2004 7:35 am
Posts: 2
Hi all,
I have a problem with (basically) the following hql query:
"select person.name, ... from Person left join person.contacts ..."

DB2 gives me an error saying: SQL0206N "AS" is not valid in the context where it is used.

Looking at the generated SQL query, I see the following:"
"SELECT ...., someTable.someColumn AS x3_0_, AS x4_0_ from PERSON ..."

So, the generated SQL is actually missing something before the second AS keyword.

I'm quite sure not do anything wrong. The same thing works if the query goes simply "select person, ... from Person left join person.contacts ..." - that is, without querying properties.

I'm using hibernate 2.1.1 (but problem is the same with 2.1.2), my database is DB2.

Any help appreciated,
J


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 30, 2004 4:13 am 
Newbie

Joined: Mon Mar 22, 2004 5:23 am
Posts: 18
Location: Bangalore
Can u post the full HQL where u r having the Problem.

Also post the HQL wich is working fine..

thanks
Santosh


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 30, 2004 4:30 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Can you please stop posting in l33t speech, it hurts.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 30, 2004 4:41 am 
Newbie

Joined: Mon Mar 29, 2004 7:35 am
Posts: 2
The "good" hql goes like this:
--------------------------------
select person, name, domizilOrt, sitze, from ch.abraxas.steuer.businesscomponent.register.persistency.struct.GenJuristischePersonInfo as person left join person.nameInfos.elements as name left join person.postAdressenKontaktInfos.elements.postAdressenInfos.elements.einfachePostAdresseInfo.standortInfo.ortInfo as domizilOrt left join person.sitzInfos.elements as sitze where name.gueltigVon <= :today1 and name.gueltigBis >= :today2 and name.name like :name

The "bad" hql goes like this:
--------------------------------
select person.integerID, name, domizilOrt, sitze, from ch.abraxas.steuer.businesscomponent.register.persistency.struct.GenJuristischePersonInfo as person left join person.nameInfos.elements as name left join person.postAdressenKontaktInfos.elements.postAdressenInfos.elements.einfachePostAdresseInfo.standortInfo.ortInfo as domizilOrt left join person.sitzInfos.elements as sitze where name.gueltigVon <= :today1 and name.gueltigBis >= :today2 and name.name like :name

The only difference is the person.integerID (which is a normal property mapped in the hbm.xml). The result is incorrectly generated SQL (seems to me, at least), which (in excerpts) goes like:

select nameinfos1_.ID_NAME as ID_NAME0_, ..., postadress4_.FK_EINFACHEPOSTADR as FK_EINF11_1_, ..., sitzinfos8_.FK_JURISTPERSON as FK_JURI12_2_, ..., genjuristi0_.PF_ABSTRAKTEPERSON as x0_0_, nameinfos1_.ID_NAME as x1_0_, postadress4_.ID_POSTADRESSE as x2_0_, sitzinfos8_.ID_SITZ as x3_0_, as x4_0_ from EN2B.T34JURISTPERSON genjuristi0_ inner join EN2B.T34ABSTRAKTEPERSON genjuristi0__1_ on genjuristi0_.PF_ABSTRAKTEPERSON=genjuristi0__1_.ID_ABSTRAKTEPERSON left outer join EN2B.T34NAME nameinfos1_ on genjuristi0_.PF_ABSTRAKTEPERSON=nameinfos1_.FK_ABSTRAKTEPERSON ... (more left outer joins) ... where postadress2_.COD_TABELLE = 'ADR' and ((nameinfos1_.AK_GUELTIGVON<=? )and(nameinfos1_.GUELTIGBIS>=? )and(nameinfos1_.NAME like ? ))

The problem is before "as x4_0_".

Thanks for the help,
J


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 31, 2004 9:44 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
And your mapping is ?

_________________
Emmanuel


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