|
From: Søren M. (J. <nh...@gm...> - 2011-03-16 12:11:43
|
[ http://216.121.112.228/browse/NH-2553?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=20660#action_20660 ]
Søren Munk commented on NH-2553:
--------------------------------
The problem is that i cannot create a reliable testcase.
I currently have 2 test, using production data. 1 which fails and 1 which does not.
Btw. by 100% pure NH, I presume that you are referring to my repositories, and not my domain objects.
[TestMethod]
public void Test1WhichFail()
{
var factory = InitFactory();
var session = factory.OpenSession();
var transaction = session.BeginTransaction();
var obj = (ZitCom.Model.Wannafind.Order)session.Get(typeof(ZitCom.Model.Wannafind.Order), 6045);
Assert.IsNotNull(obj.Customer);
session.Flush(); <-- FAILS
using (transaction)
transaction.Commit();
}
System.IndexOutOfRangeException was unhandled by user code
Message=Parameter index is out of range.
Source=MySql.Data
StackTrace:
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()
at Test.NHibernateRepository.NHibernateTests.Test1GetOrderById() in C:\Projects\TFS\Test\NHibernateRepository\NHibernateTests.cs:line 44
InnerException:
Using another id eg. 6046 does not throw the exception. Also I cannot reproduce the issue on our mssql servers, only on mysql. So my bet is that in some circumstances NH (re)uses db commands in a way that is not compatible with the mysql "driver".
Ill attach my unittest + *.hbm files. But i cannot add model/database snapshot. I am certain that it is not any code that i have written which makes it fail.
Another note: Flusing the session should'nt really do anything since no changes have been made to the obj.
> 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: Major
>
> 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
|