Hi,
I'm using Hibernate 4.1.4 (occures with 4.1.7, too) and JPA 2.0 (mappings configured by annotations). In my model, class Foo has a combined primary key with three elements and a class Bar with a x-to-one reference to Foo.
In this scenario everything seems to be fine if the primary-key-properties in Foo are sorted by name and the Join-Columns in Bar have the same order as the properties. If the order differs (assuming aId1, cId2, bId3) and the Join-Columns follow this order, Hibernate seems to resolve the values in a query (select b from Bar b) in the wrong order, respectively assign in the wrong order (select b from Bar where b.foo=:foo).
It looks like the SQL-statement is created using the order of the @JoinColumns at the association or the order of properties as defined in the class but the values are bound in alphabetical order. After some debugging I think the properties are alphabetical sorted because during creating the metamodel, the properties are stored in a TreeMap in PropertyContainer#propertyAccessMap.
Can anyone tell me, what I do wrong or confirm that this is a bug so I can create a issue in Jira? I created a trivial example with some unit-tests at git://github.com/sschulze/HibernateExample.git
|