Hello, i've been struggling to resolve the issue regarding object
insertion into IList<T> with index under NHibernate 2.0.
I have the following POCO and mapping file as Parent and Child
objects.
- Parent's POCO
public class Parent
{
public virtual decimal Id { get; set;}
......
public virtual IList<Child> Children { get; set;}
}
- Child's POCO
public vlass Child
{
public virtual decimal Id { get; set;}
public virtual Parent { get; set;}
public virtual string PropertyId { get; set;}
public virtual string PropertyValue { get; set;}
}
- Parent's mapping file
<class name="Parent" table="parents">
<id name="Id">
<generator class="native">
<param name="sequence">sq_parent</param>
</generator>
</id>
<list name="Children" cascade="all">
<key column="parent_id"/>
<index column="child_index"/>
<one-to-many class="Child"/>
</list>
</class>
- Child's mapping file
<class name="Child" table="children">
<id name="Id">
<generator class="native">
<param name="sequence">sq_child</param>
</generator>
</id>
<many-to-one name="Parent" class="Parent" column="parent_id" not-
null="true"/>
<property name="PropertyId" column="property_id"/>
<property name="PropertyValue" column="property_value"/>
</class>
Calling Parent.Children.Add(new Child(){...}) I've succeeded to update
Parent object which has already had some children objects..
But with Parent.Children.Insert(int, new Child(){})
ArgumentOutOfRangeException has been occured in transaction.Commit().
As a reference the following is stack trace (the mean showd in the
stack trace is "where the exception is occured").
System.Collections.ArrayList.get_Item(Int32 index)
場所 Oracle.DataAccess.Client.OracleParameterCollection.GetParameter
(Int32 index)
場所
System.Data.Common.DbParameterCollection.System.Collections.IList.get_Item
(Int32 index)
場所 NHibernate.Type.DecimalType.Set(IDbCommand st, Object value,
Int32 index)
場所 NHibernate.Type.NullableType.NullSafeSet(IDbCommand cmd, Object
value, Int32 index)
場所 NHibernate.Type.NullableType.NullSafeSet(IDbCommand st, Object
value, Int32 index, ISessionImplementor session)
場所
NHibernate.Persister.Collection.AbstractCollectionPersister.WriteKey
(IDbCommand st, Object id, Int32 i, ISessionImplementor session)
場所
NHibernate.Persister.Collection.AbstractCollectionPersister.PerformInsert
(Object ownerId, IPersistentCollection collection, IExpectation
expectation, Object entry, Int32 index, Boolean useBatch, Boolean
callable, ISessionImplementor session)
場所
NHibernate.Persister.Collection.AbstractCollectionPersister.InsertRows
(IPersistentCollection collection, Object id, ISessionImplementor
session)
場所 NHibernate.Action.CollectionUpdateAction.Execute()
場所 NHibernate.Engine.ActionQueue.Execute(IExecutable executable)
場所 NHibernate.Engine.ActionQueue.ExecuteActions(IList list)
場所 NHibernate.Engine.ActionQueue.ExecuteActions()
場所
NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions
(IEventSource session)
場所 NHibernate.Event.Default.DefaultFlushEventListener.OnFlush
(FlushEvent event)
場所 NHibernate.Impl.SessionImpl.Flush()
場所 NHibernate.Transaction.AdoTransaction.Commit()
場所 ParentDao.Update(Parent persistedParent, Parent parent)
場所 C:\Documents and Settings\hoge\My Documents\Visual Studio
2008\Projects\TestProject\ParentDao\Dao\ParentDao.cs:行 351
Why has this exception been only thrown in case of IList<T>.Insert()
and why not in IList<T>.Add() ?
If you have any ideas, please let me know.
Regards.
--
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.