[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2847) THIS_"."NAME": invalid identifier when using createCriteria with addOrder

Nguyen Hau Giang (JIRA) noreply at atlassian.com
Tue Oct 2 03:03:26 EDT 2007


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2847?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_28278 ] 

Nguyen Hau Giang commented on HHH-2847:
---------------------------------------

try using keyword "this" in sort property name:

HibernateUtil.getSession().createCriteria(SystemBean.class)
.addOrder(Order.asc("this.name")).list(); 


> THIS_"."NAME": invalid identifier when using createCriteria with addOrder
> -------------------------------------------------------------------------
>
>                 Key: HHH-2847
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2847
>             Project: Hibernate3
>          Issue Type: Bug
>          Components: query-criteria
>    Affects Versions: 3.0.5
>         Environment: Oracle - 10.2.0
>            Reporter: Ashish Tiwari
>            Assignee: Diego Pires Plentz
>
> We are using hibernate 3.0.5 and once a while I see following error getting generated due to incorrect SQL generated by hibernate: 
> Hibernate: select systembean0_.SYSTEMID as SYSTEMID12_0_, systembean0_.Version as Version12_0_, systembean0_.NAME as NAME12_0_, systembean0_.TYPE as TYPE12_0_, systembean0_.DESCRIPTION as DESCRIPT5_12_0_ from SDSYSTEM systembean0_ order by this_.NAME asc 
> - SQL Error: 904, SQLState: 42000 
> - ORA-00904: "THIS_"."NAME": invalid identifier 
> This normally works but occasionally we run into the issue mentioned above. I do not see alias "this_" in the sql query and I think that causes the error to happen. Issue is caused by alias not used consistently.
> In normal case the generated SQL looks like following:
> Hibernate: select this_.SYSTEMID as SYSTEMID7_0_, this_.Version as Version7_0_, this_.NAME as NAME7_0_, this_.TYPE as TYPE7_0_, this_.DESCRIPTION as DESCRIPT5_7_0_ from SDSYSTEM this_ order by this_.NAME asc
>  
> I am not sure what causes this problem. Has anyone else see similar problem earlier? 
> I appreciate any help with this. Below is other information: 
> Hibernate version: 3.0.5 
> Mapping documents: 
> <?xml version="1.0"?> 
> <!DOCTYPE hibernate-mapping PUBLIC 
> "-//Hibernate/Hibernate Mapping DTD 3.0//EN" 
> "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> 
> <hibernate-mapping> 
> <class 
> name="com.avaya.coreservice.admin.toolkit.common.system.SystemBean" 
> table="SDSYSTEM"> 
> <id name="uniqueId" type="java.lang.String"> 
> <column name="SYSTEMID" length="50" not-null="true"/> 
> <generator class="uuid"/> 
> </id> 
> <version name="version" column="Version" /> 
> <property 
> name="name" 
> type="java.lang.String"> 
> <column name="NAME" length="512" not-null="true"/> 
> </property> 
> <property 
> name="type" 
> type="java.lang.String"> 
> <column name="TYPE" length="50" not-null="false"/> 
> </property> 
> <property 
> name="description" 
> type="java.lang.String"> 
> <column name="DESCRIPTION" length="1024" not-null="false"/> 
> </property> 
> <set name="resourceBeanSet"> 
> <key> 
> <column name="SYSTEMID" length="50" not-null="false"/> 
> </key> 
> <one-to-many class="com.avaya.coreservice.admin.toolkit.common.resource.ResourceBean"/> 
> </set> 
> <set name="siteBeanSet" order-by="name asc"> 
> <key> 
> <column name="SYSTEMID" length="50" not-null="false"/> 
> </key> 
> <one-to-many class="com.avaya.coreservice.admin.toolkit.common.site.SiteBean"/> 
> </set> 
> </class> 
> </hibernate-mapping> 
> Code between sessionFactory.openSession() and session.close(): 
> HibernateUtil.getSession().createCriteria(SystemBean.class) 
> .addOrder(Order.asc("name")).list(); 
> Full stack trace of any exception that occurs: 
> N/A 
> Name and version of the database you are using: 
> Oracle - 10.2.0 
> The generated SQL (show_sql=true): 
> select systembean0_.SYSTEMID as SYSTEMID12_0_, systembean0_.Version as Version12_0_, systembean0_.NAME as NAME12_0_, systembean0_.TYPE as TYPE12_0_, systembean0_.DESCRIPTION as DESCRIPT5_12_0_ from SDSYSTEM systembean0_ order by this_.NAME asc 
> I appreciate any help with this.
> Thanks, 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list