-->
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: I can't initialize mother_id column in the Cat example
PostPosted: Sun Nov 20, 2005 9:20 am 
Newbie

Joined: Sun Nov 20, 2005 9:00 am
Posts: 3
Hi,

I'm new to nhibernate and I think I will heavily use it in the very near future. Now I'm playing with the examples. But I have a problem...

this is the code I use:
fiu(Romanian)=son(English)
mama(Romanian)=mother(English)


Code:
ClassLibrary1.Cat mama=new ClassLibrary1.Cat();
mama.Name="mama";
mama.Birthdate=DateTime.Now;

ClassLibrary1.Cat fiu1=new ClassLibrary1.Cat();
fiu1.Name="fiu1";
fiu1.Birthdate=DateTime.Now;

ClassLibrary1.Cat fiu2=new ClassLibrary1.Cat();
fiu2.Name="fiu2";
fiu2.Birthdate=DateTime.Now;

ClassLibrary1.Cat fiu3=new ClassLibrary1.Cat();
fiu3.Name="fiu3";
fiu3.Birthdate=DateTime.Now;

mama.Kittens=new Iesi.Collections.HashedSet();
mama.Kittens.Add(fiu1);
mama.Kittens.Add(fiu2);
mama.Kittens.Add(fiu3);
               
session.Save(mama);


Basically I want a cat with a few sons and when the mother is saved I want the mother_id from each son to be seted correctly. But this is not happening... :(( mother_id is NULL for every son


the mapping xml:
Code:
<?xml version="1.0" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
    <class name="ClassLibrary1.Cat, ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" table="CATS">
        <id name="Id" column="uid" type="Int64">
            <generator class="identity"/>
        </id>
        <property name="Birthdate" type="Date"/>
        <property name="Sex" not-null="true" update="false"/>
        <property name="Weight"/>
        <property name="Name"/>
        <many-to-one name="Mate" column="mate_id"/>
        <set name="Kittens" cascade="all">
            <key column="mother_id"/>
            <one-to-many class="ClassLibrary1.Cat, ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
        </set>
    </class>
</hibernate-mapping>


What am I missing?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 20, 2005 10:49 am 
Newbie

Joined: Sun Nov 20, 2005 9:00 am
Posts: 3
I didn't find out why the example didn't work. Just Implemented a tree node from scratch and worked JUST FINE! :D


Sorry, next time I'll read the docs twice


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.