[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-6698) Query Parameters Not Bound Correctly

Gail Badner (JIRA) noreply at atlassian.com
Mon Oct 24 16:13:19 EDT 2011


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

Gail Badner commented on HHH-6698:
----------------------------------

Is this still an issue in 3.6.7?

> Query Parameters Not Bound Correctly
> ------------------------------------
>
>                 Key: HHH-6698
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6698
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: query-hql, query-sql
>    Affects Versions: 3.6.0
>         Environment: Hibernate 3.6.0, Windows, Oracle 10g and MySQL 5.1
>            Reporter: Erich Heard
>         Attachments: hhh-6698.zip
>
>
> When an entity has a compound key made up of, in part, another entity's compound key, it seems that Hibernate does not bind parameters to the correct columns in SQL translated from HQL.  It seems that the routine used to build the SQL statement via Antlr can list primary key columns in a different order than the routine that builds parameter values via reflection.  Bascially, you end up with a condition like:
> PK_COL_1 = ? and 
> PK_COL_2 = ?
> and the bound values are for :pkCol2 and :pkCol1 respectively.  Depending on how an HQL query is written, you can actually get the query translator to build a join this way:
> TABLE1.PK_COL_1 = TABLE2.PK_COL_2 and 
> TABLE1.PK_COL_2 = TABLE2.PK_COL_1 
> Depending on the data type, this can either cause an error or an empty result set.  I did a good bit of debugging, but did not find an easy solution that didn't break something else worse.  I did find that explicitly setting @JoinColumn.referencedColumnName in the child ID class did force things to work correctly against Oracle but MySQL is syntactically different enough that it does not work there.  I will attach an example shortly.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list