|
From: Søren M. (J. <nh...@gm...> - 2011-03-01 13:19:18
|
Nhibernate fails to delete entity.
----------------------------------
Key: NH-2553
URL: http://216.121.112.228/browse/NH-2553
Project: NHibernate
Issue Type: Bug
Components: Core
Affects Versions: 3.0.0.GA
Reporter: Søren Munk
Priority: Critical
We get this error while committing the nh transaction. (If we dont use the transaction, we still get the error)
System.IndexOutOfRangeException: Parameter index is out of range.
at MySql.Data.MySqlClient.MySqlParameterCollection.CheckIndex(Int32 index)
at MySql.Data.MySqlClient.MySqlParameterCollection.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.Entity.AbstractEntityPersister.Dehydrate(Object id, Object[] fields, Object rowId, Boolean[] includeProperty, Boolean[][] includeColumns, Int32 table, IDbCommand statement, ISessionImplementor session, Int32 index)
at NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id, Object[] fields, Object[] oldFields, Object rowId, Boolean[] includeProperty, Int32 j, Object oldVersion, Object obj, SqlCommandInfo sql, ISessionImplementor session)
at NHibernate.Persister.Entity.AbstractEntityPersister.UpdateOrInsert(Object id, Object[] fields, Object[] oldFields, Object rowId, Boolean[] includeProperty, Int32 j, Object oldVersion, Object obj, SqlCommandInfo sql, ISessionImplementor session)
at NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id, Object[] fields, Int32[] dirtyFields, Boolean hasDirtyCollection, Object[] oldFields, Object oldVersion, Object obj, Object rowId, ISessionImplementor session)
at NHibernate.Action.EntityUpdateAction.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()
...
Our mapping is like this:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Model" namespace="Model">
<class name="ServerBillingMapping" table="rel_server_billing" lazy="true">
<id name="Id" column="rel_server_billing_id">
<generator class="native" />
</id>
<many-to-one name="Server" column="server_id" lazy="proxy" cascade="none" />
<many-to-one name="ServerType" column="servertype_id" lazy="proxy" cascade="none" />
<many-to-one name="Billing" column="billing_id" lazy="proxy" cascade="none" />
</class>
</hibernate-mapping>
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Model" namespace="Model">
<class name="Billing" table="billing" lazy="false">
<cache usage="read-write"/>
<id name="Id" column="billing_id">
<generator class="native" />
</id>
<set name="ServerMappings" lazy="true" table="rel_server_billing" cascade="all-delete-orphan">
<key column="billing_id" />
<one-to-many class="ServerBillingMapping" not-found="ignore" />
</set>
</class>
</hibernate-mapping>
Code:
var billing = repo.FindBilling(Id);
var mapping = billing.ServerMappings.Where(bla bla).FirstOrDefault();
repo.Delete(mapping);
billing.ServerMappings.Remove(mapping);
repo.Save(billing);
repo.CommitTransaction(); <-- calls flush, and fails.
We also get an error "Method not supported". If ServerBillingMapping has mappings with lazy="no-proxy". And accessing the object through the reverse mapping. Eg. Billing.ServerMappings.FirstOrDefault();
Method not supported.
at NHibernate.Proxy.AbstractProxyFactory.GetFieldInterceptionProxy() in d:\CSharp\NH\nhibernate\src\NHibernate\Proxy\AbstractProxyFactory.cs:line 49
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
|