-->
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: HQL: bad translation?
PostPosted: Wed Dec 17, 2003 5:56 am 
Newbie

Joined: Tue Sep 16, 2003 6:12 am
Posts: 13
Hi, I'm writting hql querys by joining bits of Strings as in a puzzle.
The following hql query:

Code:
select typ0.codnum, inc0.id, typ1.id, inc0.state, inc0.originCode, inc0.priorCode from attend.entity.Typology as typ0 , attend.entity.Incident as inc0  left join inc0.type as typ1  where inc0.type.code = typ0.code  order by typ0.codnum asc


it's beeing translated into SQL as:

Code:
select typology0_.typ_codnum as x0_0_, incident1_.inc_inccod as x1_0_, typology2_.typ_typcod as x2_0_, incident1_.inc_incstt as x3_0_, incident1_.inc_ogncod as x4_0_, incident1_.inc_prtcod as x5_0_ from hk_typology typology0_, hk_incident incident1_ left outer join hk_typology typology2_ on incident1_.inc_inctyp=typology2_.typ_typcod where (typology2_.typ_typcod=typology0_.typ_typcod  and ) order by  typology0_.typ_codnum asc


The where clause:

where (typology2_.typ_typcod=typology0_.typ_typcod and )

is obviously wrong. Gives me an error such as:

[Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Line 1: Incorrect syntax near ')'.

Please, tell me wether this is my hql query's fault or an hibernate translation problem.

Note that i'm using SQLServer 2000 with the following hibernate.properties:
Code:
hibernate.dialect net.sf.hibernate.dialect.SybaseDialect
hibernate.connection.driver_class = com.microsoft.jdbc.sqlserver.SQLServerDriver
hibernate.connection.url = jdbc:microsoft:sqlserver://SINFW31:1433;database=attend;SelectMethod=cursor
hibernate.connection.username = ++++++
hibernate.connection.password = ++++++
hibernate.connection.pool_size = 2
hibernate.show_sql true
hibernate.jddbc.use_scrollable_resultset true


Thank you very much in advanced!


Top
 Profile  
 
 Post subject: Re: HQL: bad translation?
PostPosted: Wed Dec 17, 2003 6:01 am 
Newbie

Joined: Tue Sep 16, 2003 6:12 am
Posts: 13
payess wrote:
Hi, I'm writting hql querys by joining bits of Strings as in a puzzle.
The following hql query:

Code:
select typ0.codnum, inc0.id, typ1.id, inc0.state, inc0.originCode, inc0.priorCode from attend.entity.Typology as typ0 , attend.entity.Incident as inc0  left join inc0.type as typ1  where inc0.type.code = typ0.code  order by typ0.codnum asc


it's beeing translated into SQL as:

Code:
select typology0_.typ_codnum as x0_0_, incident1_.inc_inccod as x1_0_, typology2_.typ_typcod as x2_0_, incident1_.inc_incstt as x3_0_, incident1_.inc_ogncod as x4_0_, incident1_.inc_prtcod as x5_0_ from hk_typology typology0_, hk_incident incident1_ left outer join hk_typology typology2_ on incident1_.inc_inctyp=typology2_.typ_typcod where (typology2_.typ_typcod=typology0_.typ_typcod  and ) order by  typology0_.typ_codnum asc


The where clause:

where (typology2_.typ_typcod=typology0_.typ_typcod and )

is obviously wrong. Gives me an error such as:

[Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Line 1: Incorrect syntax near ')'.

Please, tell me wether this is my hql query's fault or an hibernate translation problem.

Note that i'm using SQLServer 2000 with the following hibernate.properties:
Code:
hibernate.dialect net.sf.hibernate.dialect.SybaseDialect
hibernate.connection.driver_class = com.microsoft.jdbc.sqlserver.SQLServerDriver
hibernate.connection.url = jdbc:microsoft:sqlserver://SINFW31:1433;database=attend;SelectMethod=cursor
hibernate.connection.username = ++++++
hibernate.connection.password = ++++++
hibernate.connection.pool_size = 2
hibernate.show_sql true
hibernate.jddbc.use_scrollable_resultset true


Thank you very much in advanced!


By the way, i'm using hibernate 2.0.3


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 17, 2003 6:48 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
* this is fixed in 2.1, definitely
* i think it is also fixed in the main branch if you don't want to upgrade to 2.1
* there is also a workaround that involves writing the same query in a different way (forget exactly what it is though)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 17, 2003 7:39 am 
Newbie

Joined: Tue Sep 16, 2003 6:12 am
Posts: 13
Would I change it from 2.0.3 to 2.1, will it all go completly bannanas ?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 17, 2003 8:12 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Hibernate 2.1 is backward compatible with 2.0.x. The main issue might be that you need to upgrade to cglib2.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 18, 2003 5:32 am 
Newbie

Joined: Tue Sep 16, 2003 6:12 am
Posts: 13
Well, thanks a lot. I shall give it a go once I've finished with it. Haven't got much time. I've solved the problem by now. Thanks again!


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.