views:

19

answers:

1

Hello Everyone,

I have a Sponsor object which has a collection that looks like this...

public virtual IDictionary<SettingId, object> SettingValueDefaults { get; set; }

These are actually being pulled as a subset of a larger table. I need to be able to read from these, and that is working correctly.

However, I would like to be able to make run-time changes to this collection, and have nhibernate ignore those changes, or even trying to persist the collection at all.

Again, I need nhibernate to retreive the data, so I can use it in code, but not persist the data changes I make to the collection during execution.

The mapping for this collection is below :

 <map name="SettingValueDefaults" cascade="none">
   <cache usage="read-write" region="Sponsors" />
   <key not-null="true" column="SponsorId"/>
   <index column="SettingId" type="HealthTools.Core.Domain.Model.Sponsor.Settings.SettingId, HealthTools.Core"/>
   <element column="DefaultValue" type="HealthTools.Infrastructure.DataAccess.SqlVariant, HealthTools.Infrastructure"/>
   <loader query-ref="GetDefaultSettingValues" />
  </map>

Here is the error I am receiving from Nhibernate when tries to persist the Sponsor object.

"Invalid object name 'HealthTools.dbo.SettingValueDefaults"

This is occuring because there is no SettingsValueDefaults table, the map is just pulling data from the Sponsor.Settings table via the GetDefaultSettingValues function.

+2  A: 

You'll want to make it read-only:

<map name="SettingValueDefaults" cascade="none" access="readonly">
Daniel T.

related questions