-->
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.  [ 2 posts ] 
Author Message
 Post subject: Hql problem with version 3.5*
PostPosted: Thu Apr 15, 2010 8:42 am 
Newbie

Joined: Thu Apr 15, 2010 8:23 am
Posts: 1
I have this HQL, which works fine when I'm using 3.3.2.
This is not the exact table/class name of course, but the structure is the same.
Code:
         select distinct oc.ce
          from com.xxx.Asdf as oc
          where
             oc.ce.Road.Main.id = :id and
             oc.ce.Road.Ind = :ind
          order by oc.ce.Number asc, lower(oc.ce.Text) asc


but after I upgrade to 3.5 and also try it with 3.5.1,
the HQL was translated to this sql:
This is not the exact table/column name, I cannot put the real name here.
Code:
SELECT DISTINCT ce1_.ID AS id29_,
                ce1_.fk_id AS fk2_29_,
                ce1_.text AS title3_29_,
                ce1_.dur AS duration4_29_,
                ce1_.number AS seq5_29_,
                ce1_.unit AS duration6_29_,
                ce1_.fee AS per7_29_
           FROM ceAsdf map0_,
                ce ce1_,  ---------- same table repeated twice
                ce ce2_,  ---------- same table repeated twice
                ceraft map3_
          WHERE map0_.fk_id = ce_.ID
            AND map0_.fk_id = ce.ID
            AND ce2_.fk_d = map3_.ID
            AND map3_.fk_id = ?
            AND map3_.ind = ?
       ORDER BY ce2_.seq_number ASC,
                LOWER (ce2_.title_text) ASC


Notice that the
Code:
ce   ---------- same table repeated twice
table is repeated twice.
This causes problem since the ordering is using ce2, but ce2 was never in the select statement.

Code:
org.hibernate.exception.SQLGrammarException: could not execute query
   at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:92)
   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
   at org.hibernate.loader.Loader.doList(Loader.java:2297)
   at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2172)
   at org.hibernate.loader.Loader.list(Loader.java:2167)
   Truncated. see log file for complete stacktrace
java.sql.SQLException: ORA-01791: not a SELECTed expression


Anyone have any idea about this?
Should I submit a bug report?


Top
 Profile  
 
 Post subject: Re: Hql problem with version 3.5*
PostPosted: Thu Apr 15, 2010 9:25 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
I think the old behavior was a bug in Hibernate. If you explicitly join the oc.ce.Road entity the duplicate should go away. See http://opensource.atlassian.com/project ... e/HHH-4091 for more details.


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