-->
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: HQL to SQL error
PostPosted: Fri Jan 18, 2008 12:29 pm 
Newbie

Joined: Fri Jan 18, 2008 12:19 pm
Posts: 1
Hi,

I have a problem with a HQL where-clause.
When Hibernate execute this the generated SQL is wrong

Here the HQL form debug-output:
SELECT
count(*)
FROM
de.lido.vu.model.Angebotkopf
WHERE
JJJJMM BETWEEN 200801 and 200801
and LFDNR BETWEEN 0 and 99999
and SPLITT BETWEEN 0 and 99
and WMTYP BETWEEN ' ' and 'ZZZZ'
and FARBEN BETWEEN ' ' and 'ZZ'
and FACHB BETWEEN ' ' and 'ZZ'
and nvl(substr(FACHB,3,1),'')||' ' BETWEEN ' ' and 'Z '
and SCHAFT BETWEEN '-' and 'ZZ'
and MNB BETWEEN 100 and 600
and anwendung BETWEEN '00' and '0999'

The intersting code is marked bold.


And here the SQL that Hibernate generated

SELECT
count(*) as col_0_0_
FROM
oralp2.DS_ANGKOPF angebotkop0_
WHERE
(
JJJJMM BETWEEN 200801
and 200801
)
and
(
LFDNR BETWEEN 0 and 99999
)
and
(
SPLITT BETWEEN 0 and 99
)
and
(
WMTYP BETWEEN ' ' and 'ZZZZ'
)
and
(
FARBEN BETWEEN ' ' and 'ZZ'
)
and
(
FACHB BETWEEN ' ' and 'ZZ'
)
and
(
(
nvl(substr(FACHB, 3, 1)||'')||' '
)
BETWEEN ' ' and 'Z '
)

and
(
SCHAFT BETWEEN '-' and 'ZZ'
)
and
(
MNB BETWEEN 100 and 600
)
and
(
angebotkop0_.anwendung BETWEEN '00' and '0999'
)

The interesting code which is wrong is also markd bold.
My question is where comes the first ||? In the HQL this was an comma.
Why ist Hibernate change this to ||.
I have to do such an beast because I have to support Oracle and PostgreSQL. Both databases differ in the result of a blank substr.
Have anyone and idea.

Thank you

Regards

Wolfgang


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.