You cannot have mutliple items (properties or collections) mapped to the
same column, unless you add update="false" insert="false" to one of them. I
ran into that issue when trying to have a discriminator and map the
discriminator column to a property as well. Note that that effectively makes
that item read-only.

On Mon, Oct 27, 2008 at 8:19 AM, Tigraine <[EMAIL PROTECTED]> wrote:

>
> Hi,
>
> I have a Entity called Person that should have a Parent property. The
> Parent property is a FK reference to the parent Person and can be
> null.
> Now, I decided that performance wise it's easier to simply get all
> Persons in a flat list, and create the tree in memory.
>
> To accomplish this (my ParentPerson property is lazy loaded) I tried
> to introduce a new Field to the Domain Object called ParentPersonId
> that maps so the same column as the many-to-one relationship.
>
> After I ran my Unit Tests everything failed with the following stack
> trace:
>
> System.IndexOutOfRangeException: Ungültiger Index 33 für
> SqlParameterCollection mit Count=33.
> bei System.Data.SqlClient.SqlParameterCollection.RangeCheck(Int32
> index)
> bei System.Data.SqlClient.SqlParameterCollection.GetParameter(Int32
> index)
> bei
>
> System.Data.Common.DbParameterCollection.System.Collections.IList.get_Item(Int32
> index)
> bei NHibernate.Type.Int64Type.Set(IDbCommand rs, Object value, Int32
> index)
> bei NHibernate.Type.NullableType.NullSafeSet(IDbCommand cmd, Object
> value, Int32 index)
> bei NHibernate.Type.NullableType.NullSafeSet(IDbCommand st, Object
> value, Int32 index, ISessionImplementor session)
> bei
> NHibernate.Persister.Entity.AbstractEntityPersister.Dehydrate(Object
> id, Object[] fields, Object rowId, Boolean[] includeProperty, Boolean[]
> [] includeColumns, Int32 table, IDbCommand statement,
> ISessionImplementor session, Int32 index)
> bei NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object
> id, Object[] fields, Boolean[] notNull, Int32 j, SqlCommandInfo sql,
> Object obj, ISessionImplementor session)
> bei NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object
> id, Object[] fields, Object obj, ISessionImplementor session)
> bei NHibernate.Action.EntityInsertAction.Execute()
> bei NHibernate.Engine.ActionQueue.Execute(IExecutable executable)
> bei NHibernate.Engine.ActionQueue.ExecuteActions(IList list)
> bei NHibernate.Engine.ActionQueue.ExecuteActions()
> bei
>
> NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions(IEventSource
> session)
> bei
> NHibernate.Event.Default.DefaultFlushEventListener.OnFlush(FlushEvent
> event)
> bei NHibernate.Impl.SessionImpl.Flush()
> bei NHibernate.Transaction.AdoTransaction.Commit()
> bei
>
> mlmManager.Repositories.NHibernate.Tests.PersonRepository_Fixture.CreateInitialData()
> in PersonRepository_Fixture.cs: line 122.
> bei
>
> mlmManager.Repositories.NHibernate.Tests.PersonRepository_Fixture.SetupContext()
> in PersonRepository_Fixture.cs: line 22.
>
> Sorry it's in german, "bei" means at and the top line says "Invalid
> Index 33 for SqlParameterCollection with Count=33"
>
> The mapping file looks like this:
>
> <class name="Person">
>    <id name="Id" type="Int64">
>      <generator class="hilo" />
>    </id>
>    <property name="ParentPersonId" column="ParentId" type="Int64" />
>    <many-to-one name="Parent" class="Person" column="ParentId" />
>
>    <set name="Children" cascade="all-delete-orphan">
>      <key column="ParentId" foreign-key="fk_Person_ParentPerson" />
>      <one-to-many class="Person"/>
>    </set>
> </class>
>
> (I omitted the irrelevant value fields).
>
> Maybe you have an Idea why I am getting this error? I can't really
> figure it out..
>
> greetings
>
> Daniel Hoelbling
> http://www.tigraine.at
> >
>

--~--~---------~--~----~------------~-------~--~----~
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