[hibernate-issues] [Hibernate-JIRA] Updated: (HHH-2866) The order of parameters is not maintained between HQL and SQL, but the parameters are inserted into the PreparedStatement in their HQL order.

Steve Ebersole (JIRA) noreply at atlassian.com
Wed Oct 3 01:39:26 EDT 2007


     [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2866?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Steve Ebersole updated HHH-2866:
--------------------------------

         Assignee: Steve Ebersole
    Fix Version/s: antlr-rework

Yes, this one is annoying.  However it :
1) is nearly impossible to fix without major changes
2) has a trivial workaround : use named parameters

> The order of parameters is not maintained between HQL and SQL, but the parameters are inserted into the PreparedStatement in their HQL order.
> ---------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HHH-2866
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2866
>             Project: Hibernate3
>          Issue Type: Bug
>          Components: query-hql
>    Affects Versions: 3.2.5
>         Environment: Hibernate 3.2.5.ga; both with MySQLInnoDB and H2 dialects; both with annotations and hand written mapping files
>            Reporter: Benjamin Keil
>            Assignee: Steve Ebersole
>             Fix For: antlr-rework
>
>         Attachments: ReorderedParameters.java, ReorderedParameters.zip
>
>
> The HQL query 
> from Assoc a where a.type.oid = ? and a.constituents[?].oid = ?
> gets translated into
> select
>         reorderedp0_.oid as oid1_,
>         reorderedp0_.type_oid as type2_1_
>     from
>         Assoc reorderedp0_,
>         Assoc_Topic constituen1_,
>         Topic reorderedp2_
>     where
>         reorderedp0_.oid=constituen1_.Assoc_oid
>         and constituen1_.topic_index = ?
>         and constituen1_.constituents_oid=reorderedp2_.oid
>         and reorderedp0_.type_oid=?
>         and reorderedp2_.oid=?
> Where clearly the first and second parameters (the index and the type) have been permuted.
> The relevant thread in the User forum is : http://forum.hibernate.org/viewtopic.php?t=979832
> Attached are a java source file that demonstrates the error, and a zipped maven2 project that supplies the Hibernate, Hibernate-Annotation, H2, and Log4J dependencies.

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