Hello,

i'm using NHibernate 2.1 and i'm having issues saving object using
components. Here is my mapping :

        <class name="Parent" table="Parent" >
                ...

                <many-to-one name="Child" class="Child" cascade="all" />
        </class>

        <class name="Child" table="Child">
                ...

                <component name="Component" class="Component">
                        <property name="Value" column="ComponentValue" />
                </component>
        </class>

So i have a simple structure Parent -> Child -> Component. What i'm
trying to do is to save my Child in cascade when saving my Parent :

1)
            Parent parent = new Parent();
            Create (parent);

            Child child = new Child();
            parent.Child = child;

            Update (parent);

But the Update raises the following exception :

failed: System.NullReferenceException
        à (Object , Object[] , SetterCallback )
        à
NHibernate.Bytecode.Lightweight.AccessOptimizer.SetPropertyValues(Object
target, Object[] values)
        à
NHibernate.Tuple.Component.PocoComponentTuplizer.SetPropertyValues(Object
component, Object[] values)
        à NHibernate.Type.ComponentType.SetPropertyValues(Object component,
Object[] values, EntityMode entityMode)
        à NHibernate.Type.TypeFactory.ReplaceAssociations(Object[] original,
Object[] target, IType[] types, ISessionImplementor session, Object
owner, IDictionary copyCache, ForeignKeyDirection foreignKeyDirection)
        à
NHibernate.Event.Default.DefaultMergeEventListener.CopyValues(IEntityPersister
persister, Object entity, Object target, ISessionImplementor source,
IDictionary copyCache, ForeignKeyDirection foreignKeyDirection)
        à
NHibernate.Event.Default.DefaultMergeEventListener.EntityIsTransient(MergeEvent
event, IDictionary copyCache)
        à
NHibernate.Event.Default.DefaultMergeEventListener.OnMerge(MergeEvent
event, IDictionary copyCache)
        à NHibernate.Impl.SessionImpl.FireSaveOrUpdateCopy(IDictionary
copiedAlready, MergeEvent event)
...

However, the following codes work fine :

2)
            Parent parent = new Parent();
            Create (parent);

            Child child = new Child()
            child.Component = new Component ();
            parent.Child = child;

            Update (parent);

3)
            Parent parent = new Parent ();
            Child child = new Child ();
            parent.child = child;
            Save (parent);

Does anyone see what could be wrong in my code ? To me, it looks like
a bug, but i want to be sure before reporting.

Thanks,

Ben

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to