-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Wrong property-order in foreign keys using JPA
PostPosted: Thu Sep 20, 2012 7:42 am 
Newbie

Joined: Wed Feb 29, 2012 5:55 am
Posts: 6
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.