-->
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: Bug? with NHMA processing of CompositeId
PostPosted: Thu Oct 04, 2007 2:26 pm 
Newbie

Joined: Mon Sep 26, 2005 12:34 pm
Posts: 7
I think I've found a bug in the processing of CompositeId attributes in NHMA. Specifically, it insists that KeyProperty items come before KeyManyToOne items. If a KeyManyToOne comes first, it will ignore all KeyProperty items that follow it!

I have a (fairly) simple object that has a composite key consisting of a many-to-one reference to a parent object, and an index (parent sees this as a list), in that order.

The nhibernate-mapping-2.2 xsd allows key-property and key-many-to-one elements can be mixed and matched in any order within composite-id. So I specified things like so:

[Class(...)]
public class Foo {
[CompositeId(1)]
[KeyManyToOne(2, Name="Parent", Column="bar_id")]
[KeyProperty(3, Name="Index", Column="foo_index")]
public Bar Parent {get;set;}
public int Index {get;set;}
}

The resultant mapping generated looks like so:
<hibernate-mapping ...>
<class ...>
<composite-id>
<key-many-to-one .../>
</composite-id>
</class>
</hibernate-mapping>

Note the missing key-property.

If I switch the order of the two Key attributes, I get both keys included. I checked the code for HbmWriter.WriteCompositeId, and this seems to be somewhat deliberate, is there a particular reason for it?

Hibernate version: NHibernate 1.2.0.GA


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.