-->
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.  [ 2 posts ] 
Author Message
 Post subject: 3.2.0.cr3 transposed field names
PostPosted: Thu Jul 27, 2006 11:23 am 
Newbie

Joined: Wed Apr 26, 2006 11:39 am
Posts: 8
Location: bracknell, UK
I've got an annotated entity with an embedded ID having a couple of numeric fields. I'm navigating to it like x.getID().getFoo() and x.getID().getBar() but it's returning the foo and bar fields transposed. When I turn hibernate's logging level to debug, I can see they're being fetched out of the sql correctly

27 Jul 2006 15:56:47 DEBUG org.hibernate.type.IntegerType : returning '29' as column: foo4_8_0_
27 Jul 2006 15:56:47 DEBUG org.hibernate.type.LongType : returning '2' as column: bar5_8_0_

but then being garbled and transposed

27 Jul 2006 15:56:47 DEBUG org.hibernate.event.def.DefaultLoadEventListener : loading entity: [com.blah.Item#component[bar,foo]{bar=29, foo=2}]

Since all the items are attributed with their column names, there ought to be no way this can happen.

This is with hibernate3.jar 3.2.0.cr3 and hibernate-annotations.jar 3.2.0.CR1, the versions from the latest Eclipse hibernate tools.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 28, 2006 10:01 am 
Newbie

Joined: Wed Apr 26, 2006 11:39 am
Posts: 8
Location: bracknell, UK
Ok, for the record, I've tracked this down.

Quoting the annotations manual:

Quote:
Composite foreign keys (if not using the default sensitive values) are defined on associations using the @JoinColumns element, which is basically an array of @JoinColumn. It is considered a good practice to express referencedColumnNames explicitly. Otherwise, Hibernate will suppose that you use the same order of columns as in the primary key declaration.


Oops.


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

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.