Hello,
In summary, with help from the individually mapped component
properties; but this seems like a bit of a disconnect between the data
model and the domain model?
I am getting an exception mapping a null value for a mapped component
property: "not-null property references a null or transient value".
I seem to recall that if all properties of a mapped component are
null, that the value of the component itself will be null. Fair
enough. But what about the reverse, such as when mapping *to* the
database, not reading *from* the database.
I'm generally looking for a "Nullable" extension method on the
component map method? But I don't see one, per se.
Ah, I think I partially answered my own question, but something of a
minor follow on question appears. The properties of the model itself
are not nullable; I don't think they should be, but there may be a
null for an instance of the component. However, Nullable should be
there for the individual component property mappings.
I wish there were a better way to coordinate this disconnect, because
it seems like something of a risk if some of the values were null, but
not all. Like, somehow a protected method in the ComponentMap class,
or on Component(). Yes, no, maybe?
The exception:
NHibernate.PropertyValueException occurred
HResult=-
2146232832
Message=not-null property references a null or transient value
Football.Models.Instruction.Zone
Source=NHibernate
EntityName=Football.Models.Instruction
PropertyName=Zone
StackTrace:
at NHibernate.Engine.Nullability.CheckNullability(Object[]
values, IEntityPersister persister, Boolean isUpdate)
at NHibernate.Event.Default.AbstractSaveEventListener.PerformSaveOrReplicate(Object
entity, EntityKey key, IEntityPersister persister, Boolean
useIdentityColumn, Object anything, IEventSource source, Boolean
requiresImmediateIdAccess)
at NHibernate.Event.Default.AbstractSaveEventListener.PerformSave(Object
entity, Object id, IEntityPersister persister, Boolean
useIdentityColumn, Object anything, IEventSource source, Boolean
requiresImmediateIdAccess)
at NHibernate.Event.Default.AbstractSaveEventListener.SaveWithGeneratedId(Object
entity, String entityName, Object anything, IEventSource source,
Boolean requiresImmediateIdAccess)
at NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.SaveWithGeneratedOrRequestedId(SaveOrUpdateEvent
event)
at NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.EntityIsTransient(SaveOrUpdateEvent
event)
at NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.PerformSaveOrUpdate(SaveOrUpdateEvent
event)
at NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.OnSaveOrUpdate(SaveOrUpdateEvent
event)
at NHibernate.Impl.SessionImpl.FireSaveOrUpdate(SaveOrUpdateEvent event)
at NHibernate.Impl.SessionImpl.SaveOrUpdate(Object obj)
at Football.Data.Repository.NHibernateRepository.SaveOrUpdate[T](T[]
items) in d:\Source\Kingdom
Software\FootballSimulator\Working\src\Football.Data.NHibernate\Repository\NHibernateRepository.cs:line
129
InnerException:
Thanks,
Michael Powell