-->
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: foreign-key attribute in one-to-many is ignored?
PostPosted: Mon Jun 26, 2006 4:30 am 
Newbie

Joined: Mon Jun 26, 2006 4:19 am
Posts: 3
The following hbm.xml contains a on-to-many mapping for a property called Descriptions.
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
    <class name="X.Core.Data.Model, X.Core.Data" table="model" lazy="false">
        <id name="Name" column="`Name`" type="String">
            <generator class="assigned" />
        </id>
        <property name="DescriptionResId" type="Guid" />

        <bag name="Descriptions" table="ResourceStrings" lazy="false" >
            <key column="ResourceId" foreign-key="DescriptionResId" />
            <one-to-many class="X.Core.Data.ResourceString, X.Core.Data" />
        </bag>
        <bag name="Features" table="Model2Feature" lazy="false">
            <key column="ModelName" />
            <many-to-many class="X.Core.Data.Feature, X.Core.Data" column="FeatureName" />
        </bag>
    </class>
</hibernate-mapping>


As you can see, I have set 'DescriptionResId' as the foreign-key. When I run my getter-code I get an exception, though. I've noticed that the generated SQL is OK, except for the where clause parameter. The parameter is assigned the Name of the Model instance (the PK of the Model table) and not the DescriptionResId I asked NHibernate to use.

Looking at the NHibernate source made me suspect that the foreign-key attribute is ignored for one-to-many mappings...

Am I correct, or just missing the obvious?

Thanks,

G.


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.