[hibernate-issues] [Hibernate-JIRA] Created: (HHH-2386) createQuery() converts JPQL into incorrect SQL

Dean Schulze (JIRA) noreply at atlassian.com
Fri Jan 26 11:19:19 EST 2007


createQuery() converts JPQL into incorrect SQL
----------------------------------------------

         Key: HHH-2386
         URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2386
     Project: Hibernate3
        Type: Bug

  Components: query-hql  
    Versions: 3.2.0.cr2    
 Environment: Hibernate 3.2.0.cr2, JBoss 4.0.4 GA, PostgreSQL  8.1
    Reporter: Dean Schulze


This JPQL query String gets converted into incorrect SQL (shown with <property name="hibernate.show_sql" value="true" />):

select cpt.name from CoveragePathTemplate cpt, CommonTemplate com where ( (cpt.id=com.id) and (com.cid in (608)) )

The generated SQL is

    select
        coveragepa0_.name as col_0_0_ 
    from
        CoveragePathTemplate coveragepa0_,
        commontemplate commontemp1_ 
    where
        coveragepa0_.id=commontemp1_.cid 
        and (
            commontemp1_.cid in (
                608
            )
        )

The first component in the where clause should be

    coveragepa0_.id=commontemp1_.id

When converting to SQL Hibernate has changed the field from id to cid.

The JPQL query string above runs as SQL and returns the proper result set.  Changing the first component in the where clause from .cid to .id also gives the proper result.

There is no mapping between the two classes in this query.


-- 
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