-->
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: Bug in Hibernate 4.1.6 with JPQL
PostPosted: Tue Apr 28, 2015 10:35 am 
Newbie

Joined: Tue Apr 28, 2015 10:29 am
Posts: 1
Hello,

I'm using QueryDSL to access my database via Hibernate (JPA). QueryDSL generates the following JPQL which itself is translated to a wrong SQL query.
JPQL
Code:
select
    qtCharacteristicHeaderMapping,
    qtCharacteristicHeader.tblLanguageKey.varKey,
    qtCharacteristicHeader.intOrder,
    qtCharacteristicGroup.intCharacteristicGroupId,
    qtCharacteristicGroup.tblLanguageKey.varKey,
    qtCharacteristic.intCharacteristicId,
    qtCharacteristic.tblLanguageKey.varKey,
    qtCharacteristic.tblFieldType.intFieldTypeId
from
    TblCharacteristicHeaderMapping qtCharacteristicHeaderMapping
    inner join qtCharacteristicHeaderMapping.tblComponentTypeCharacteristicHeader as qtComponentTypeCharacteristicHeader
    inner join qtComponentTypeCharacteristicHeader.tblCharacteristicHeader as qtCharacteristicHeader
    left join qtCharacteristicHeaderMapping.tblCharacteristicGroup as qtCharacteristicGroup
    inner join qtCharacteristicHeaderMapping.tblCharacteristic as qtCharacteristic
where
    qtCharacteristicHeader.intHeaderType = ?1
order by
    qtCharacteristicGroup.intOrder asc


SQL
Code:
select
    tblcharact0_.intCharacteristicHeaderMappingID as col_0_0_,
    tbllanguag5_.varKey as col_1_0_,
    tblcharact3_.intCharacteristicGroupID as col_2_0_,
    tbllanguag6_.varKey as col_3_0_,
    tblcharact4_.intCharacteristicID as col_4_0_,
    tbllanguag7_.varKey as col_5_0_,
    tblcharact4_.intFieldTypeID as col_6_0_,
    tblcharact0_.intCharacteristicHeaderMappingID as intChara1_3498_,
    tblcharact0_.intCharacteristicID as intChara2_3498_,
    tblcharact0_.intCharacteristicGroupID as intChara3_3498_,
    tblcharact0_.intComponentTypeCharacteristicHeaderID as intCompo4_3498_
from
    DB.dbo.tblCharacteristicHeaderMapping tblcharact0_
inner join
    DB.dbo.tblComponentTypeCharacteristicHeader tblcompone1_
        on tblcharact0_.intComponentTypeCharacteristicHeaderID=tblcompone1_.intComponentTypeCharacteristicHeaderID
inner join
    DB.dbo.tblCharacteristicHeader tblcharact2_
        on tblcompone1_.intCharacteristicHeaderID=tblcharact2_.intCharacteristicHeaderID,
    dbo.tblLanguageKey tbllanguag5_
left outer join
    DB.dbo.tblCharacteristicGroup tblcharact3_
        on tblcharact0_.intCharacteristicGroupID=tblcharact3_.intCharacteristicGroupID,
    dbo.tblLanguageKey tbllanguag6_
left outer join
    DB.dbo.tblCharacteristic tblcharact4_
        on tblcharact0_.intCharacteristicID=tblcharact4_.intCharacteristicID,
    dbo.tblLanguageKey tbllanguag7_
where
    tblcharact2_.intLanguageContentID=tbllanguag5_.intLanguageContentID
    and tblcharact3_.intLanguageContentID=tbllanguag6_.intLanguageContentID
    and tblcharact4_.intLanguageContentID=tbllanguag7_.intLanguageContentID
    and tblcharact2_.intHeaderType=?
order by
    tblcharact3_.intOrder asc


The error of the MSSQL12 server:
Code:
Msg 4104, Level 16, State 1, Line 24
The multi-part identifier "tblcharact0_.intCharacteristicGroupID" could not be bound.
Msg 4104, Level 16, State 1, Line 28
The multi-part identifier "tblcharact0_.intCharacteristicID" could not be bound.


The reason for this errors is the wrong FROM clause, which contains multiple tblLanguageKey references, but at the wrong position. They must be at the end of the FROM clause, not between the JOINS. Do you have any Idea in which version this was fixed or if this is still an error? I can't find any information and I', unable to test a newer Hibernate version.

Thanks.


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.