The order of parameters is not maintained between HQL and SQL, but the parameters are inserted into the PreparedStatement in their HQL order.

Description

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.

Environment

Hibernate 3.2.5.ga; both with MySQLInnoDB and H2 dialects; both with annotations and hand written mapping files

Status

Assignee

Steve Ebersole

Reporter

Benjamin Keil

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

3.2.5

Priority

Major