-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Saving collection with all-delete-orphan using Oracle (ODP)
PostPosted: Mon Sep 01, 2008 11:49 am 
Newbie

Joined: Mon Sep 01, 2008 11:27 am
Posts: 2
Location: London
nHibernate 2

HBM.xml mapping

<list name="Fields" fetch="join" cascade="all-delete-orphan" lazy="false">
<key column="ViewID" foreign-key="fk_ViewID"></key>
<index column="fieldorder" />
<one-to-many class="Field"/>
</list>

Code in the session using (ISession session = PersistenceSession.NewSession)
{
using (ITransaction transaction = session.BeginTransaction())
{
try
{
session.SaveOrUpdate(obj);
session.Flush();
transaction.Commit();
}
catch (Exception ex)
{
transaction.Rollback();
throw new Exception("An error has occurred : " + ex.Message, ex);
}
}
}

Full stack trace of any exception that occurs:
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at System.Collections.ArrayList.get_Item(Int32 index)
at Oracle.DataAccess.Client.OracleParameterCollection.GetParameter(Int32 index)
at System.Data.Common.DbParameterCollection.System.Collections.IList.get_Item(Int32 index)
at NHibernate.Type.Int32Type.Set(IDbCommand rs, Object value, Int32 index)
at NHibernate.Type.NullableType.NullSafeSet(IDbCommand cmd, Object value, Int32 index)
at NHibernate.Type.NullableType.NullSafeSet(IDbCommand st, Object value, Int32 index, ISessionImplementor session)
at NHibernate.Persister.Collection.AbstractCollectionPersister.WriteKey(IDbCommand st, Object id, Int32 i, ISessionImplementor session)
at NHibernate.Persister.Collection.AbstractCollectionPersister.InsertRows(IPersistentCollection collection, Object id, ISessionImplementor session)
at NHibernate.Action.CollectionUpdateAction.Execute()
at NHibernate.Engine.ActionQueue.Execute(IExecutable executable)
at NHibernate.Engine.ActionQueue.ExecuteActions(IList list)
at NHibernate.Engine.ActionQueue.ExecuteActions()
at NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions(IEventSource session)
at NHibernate.Event.Default.DefaultFlushEventListener.OnFlush(FlushEvent event)
at NHibernate.Impl.SessionImpl.Flush()
at Persistence.Repository.Save(Object obj) in Repository.cs: line 49

Name and version of the database you are using : Oracle 10g with the ODP drivers.

There is no issue if I use the Oracle drivers from microsoft. Also no issue if I use SQL Server instead.


To recreate, I populate the collection, then save the parent.
Get the parent back from the database, then call .Clear; on the collection, and resave the parent. ie

View view = new View();

IField field = Factory.NewField("test" + Guid.NewGuid());
view.fields.add(field);
Repository.Save(view);

View viewFromDB = Repository.GetView(view.ID);
viewFromDB .fields.Clear();

IField field2 = Factory.NewField("test" + Guid.NewGuid());
viewFromDB.fields.add(field);
viewFromDB.fields.add(field2);

Repository.Save(viewFromDB);


The problem seems to be with the dispose method of the oracleCommand object clearing the parameters collection, but I'm no expert.

I can work around it by clearing the collection, saving, then adding more items, but this isn't satisfactory.

Any ideas?


Top
 Profile  
 
 Post subject: moved to the jira
PostPosted: Tue Sep 16, 2008 5:48 am 
Newbie

Joined: Mon Sep 01, 2008 11:27 am
Posts: 2
Location: London
This question has been moved to the Jira, with a sample failing test
http://jira.nhibernate.org/browse/NH-1477


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.