-->
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: Readonly Collection with back field
PostPosted: Wed Jan 12, 2011 12:58 pm 
Newbie

Joined: Wed Sep 08, 2010 6:38 am
Posts: 9
I have a readonly backing field of Ilist which is exposed with a property IEnumerable. The backing field does not get initialised, but the IEnumerable List does and ends up pointing to an NHibernate collection as it should.

The problem occurs in the subclass RootTemplateItem only. The mapping is created by fluent and automapping, so I was wondering if anyone with more hbm.xml experience could check the map.

<bag access="nosetter.camelcase-underscore" cascade="all-delete-orphan" inverse="true" lazy="true" name="SubItems" mutable="true">
<key>
<column name="Parent_id" />
</key>
<one-to-many class="DTE.Business.Domain.Model.Forms.AssessmentTemplate.TemplateItem, DTE.Business, Version=0.0.2.0, Culture=neutral, PublicKeyToken=null" />
</bag>

<joined-subclass name="DTE.Business.Domain.Model.Courses.RootTemplateItem, DTE.Business, Version=0.0.2.0, Culture=neutral, PublicKeyToken=null" table="DTE_RootTemplateItem">
<key>
<column name="TemplateItem_id" />
</key>
<bag access="field.camelcase" cascade="all-delete-orphan" inverse="true" lazy="true" name="SubItems" mutable="true">
<key>
<column name="Parent_id" />
</key>
<one-to-many class="DTE.Business.Domain.Model.Forms.AssessmentTemplate.TemplateItem, DTE.Business, Version=0.0.2.0, Culture=neutral, PublicKeyToken=null" />
</bag>
<many-to-one access="backfield" class="DTE.Business.Domain.Model.Courses.AssessmentTemplate, DTE.Business, Version=0.0.2.0, Culture=neutral, PublicKeyToken=null" name="Template">
<column name="Template_id" />
</many-to-one>
</joined-subclass>


protected readonly IList<TemplateItem> _subItems = new List<TemplateItem>();

public virtual IEnumerable<TemplateItem> SubItems
{
get
{
return _subItems;
}
}


Top
 Profile  
 
 Post subject: Re: Readonly Collection with back field
PostPosted: Thu Jan 13, 2011 6:28 am 
Newbie

Joined: Wed Sep 08, 2010 6:38 am
Posts: 9
This turned out to be caused by the property returning a proxy which was of the base type, not the actual type and somehow therefore not correctly intializing the collection?? However the proxy type not returning the correct type is a known issue \ feature caused be limitations of .net and a reluctance on my part to create meaningless interfaces to cover every type in my domain just to satisify Nhibernate :)


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.