We are using NHibernate with a legacy database, please help us:
With this Entity:
public class OrderSuitInfo
{
private int orderAmount = 1;
public long OrderId { get; set; }
public string Code { get; set; }
public string Name { get; set; }
public int OrderAmount
{
get { return orderAmount; }
set { orderAmount = value; }
}
public int SuitId { get; set; }
public decimal Price { get; set; }
public decimal VPrice { get; set; }
public override bool Equals(object obj)
{
return base.Equals(obj);
}
public override int GetHashCode()
{
return GetHashCode();
}
}
and this hbm:
<class name="Vancl.Order.Domain.Model.Order.OrderSuitInfo,
Vancl.Order.Domain" table="OrderSuit" lazy="false">
<composite-id>
<key-property name ="OrderId" column="FormCode"></key-
property>
<key-property name ="SuitId" column="SuitRowNo"></key-
property>
<key-property name ="Code" column="SuitCode"></key-property>
</composite-id>
<property name ="OrderId" column="FormCode" />
<property name ="SuitId" column="SuitRowNo" />
<property name ="Code" column="SuitCode" />
<property name="Name" column="SuitName" />
<property name="VPrice" column="VPrice" />
<property name="Price" column="Price" />
</class>
got this exception:
System.IndexOutOfRangeException: Invalid index 6 for this
SqlParameterCollection with Count=6.
at System.Data.SqlClient.SqlParameterCollection.RangeCheck(Int32
index)
at System.Data.SqlClient.SqlParameterCollection.GetParameter(Int32
index)
at
System.Data.Common.DbParameterCollection.System.Collections.IList.get_Item
(Int32 index)
at NHibernate.Type.Int64Type.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.Type.ComponentType.NullSafeSet(IDbCommand st, Object
value, Int32 begin, 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.Insert(Object
id, Object[] fields, Boolean[] notNull, Int32 j, SqlCommandInfo sql,
Object obj, ISessionImplementor session)
at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object
id, Object[] fields, Object obj, ISessionImplementor session)
at NHibernate.Action.EntityInsertAction.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
Spring.Data.NHibernate.HibernateAccessor.FlushIfNecessary(ISession
session, Boolean existingTransaction)
at Spring.Data.NHibernate.HibernateTemplate.Execute(IHibernateCallback
action, Boolean exposeNativeSession)
at Spring.Data.NHibernate.Generic.HibernateTemplate.Save(Object
entity)
at XX.Order.Data.NHibernate.Order.OrderRepos.SaveOrderSuit
(OrderSuitInfo orderSuitInfo)
at
_dynamic_XX.Order.Data.NHibernate.Order.OrderRepos.SaveOrderSuit
(Object ,
Object[] )
at Spring.Reflection.Dynamic.SafeMethod.Invoke(Object target, Object[]
arguments)
at Spring.Aop.Framework.DynamicMethodInvocation.InvokeJoinpoint()
at
Spring.Aop.Framework.AbstractMethodInvocation.Proceed()
at
XX.Aspects.Logging.CommonLoggingAroundAdvice.Invoke(IMethodInvocation
invocation)
at
Spring.Aop.Framework.AbstractMethodInvocation.Proceed()
at
Spring.Aop.Framework.DynamicProxy.AdvisedProxy.Invoke(Object proxy,
Object target, Type targetType, MethodInfo targetMethod, MethodInfo
proxyMethod, Object[] args, IList interceptors)
at CompositionAopProxy_f49685df44cf4701a3662367ba1f8883.SaveOrderSuit
(OrderSuitInfo orderSuitInfo)
at XX.Order.Domain.Model.Order.OrderService.SaveWholeOrder(OrderInfo
orderInfo) in OrderService.cs: line 58
at
XX.Order.Domain.Model.Order.OrderService.Create(OrderInfo orderInfo)
in OrderService.cs: line 37
at
XX.Services.OBSImpl.Order.OrderService.Create(CartDTO cart) in
OrderService.cs: line 97
at
XX.Order.Services.OBSImpl.Tests.OrderIntegrationTest.CreateOrderTest
()
in OrderIntegrationTest.cs: line 165
any ideas?
--
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.