-->
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: NHibernate one to many problem
PostPosted: Mon Jan 04, 2010 6:03 am 
Newbie

Joined: Tue Jul 28, 2009 8:28 am
Posts: 18
Hi I'm trying to map some tables using Nhibernate and it generally works apart from when it comes to one-to-many classes. I have a Visits table where each visit has many Inspection records.

The mapping file for Visits contains the following:

Code:
<bag  name="Inspections" lazy="false" fetch="select" cascade="none" inverse="true">
         <key column="VISIT_COUNTER"/>                        
         <one-to-many class="Inspection"/>         
</bag>


The mapping file for Inspections contains the following:

Code:
<many-to-one name="ParentVisit" class="Visits" column="VISIT_COUNTER" fetch="select" lazy="false"/>


Now within the Visits class file I call an IList of Inspections using the following:

Code:
private IList<Inspection> mInspections;

public virtual IList<Inspection> Inspections
{
   get { return mInspections; }
   set { mInspections = value; }
}


Then within the Inspection class file I have the following:

Code:
private int? mUniqueID;

public virtual int? UniqueId
{
   get { return mUniqueID; }
   set { mUniqueID = value; }
}


Whenever I step through the code (using Visual Studio 2008) I reach the line set { mUniqueID = value; } within the Inspection class and it falls over with the error:

Code:
ERROR [TestRunnerThread] ADOExceptionReporter [(null)]- The given key was not present in the dictionary.


Could somebody please help me with this as it's taking me ages to work out!


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.