我正在尝试插入一个对象,但它抛出了我Error: dehydrating property value for FrancosPoS.DBMapping.order.obs
我在这里寻找
使用 NHibernate 接收超出范围的索引,但它们都不起作用。
我已经检查并重新检查了我对多列声明的映射,但没有发现任何问题。
我的线索是问题与 MySQL 数据库上的 bigint 和identity generator
. 当我将其更改为increment
脱水错误消失并Index out of range
出现异常。
此外,这发生在Session Save
通话中。使用increment
生成器,错误有时会发生commit
。
这是我的订单 xml 映射:
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping assembly="FrancosPoS" namespace="FrancosPoS.DBMapping" xmlns="urn:nhibernate-mapping-2.2">
<class name="order" table="`order`" lazy="true" >
<id name="idOrder">
<generator class="identity" />
</id>
<many-to-one lazy="false" name="employee">
<column name="idEmployee" sql-type="bigint(20)" not-null="false" />
</many-to-one>
<many-to-one lazy="false" name="customer">
<column name="idCustomer" sql-type="bigint(20)" not-null="false" />
</many-to-one>
<many-to-one lazy="false" name="address">
<column name="idAddress" sql-type="bigint(20)" not-null="false" />
</many-to-one>
<property name="date">
<column name="date" sql-type="datetime" not-null="true" />
</property>
<property name="bakingTime">
<column name="date" sql-type="datetime" not-null="false" />
</property>
<property name="price">
<column name="price" sql-type="decimal(8,4)" not-null="true" />
</property>
<property name="cash">
<column name="cash" sql-type="tinyint(1)" not-null="false" />
</property>
<property name="credit">
<column name="credit" sql-type="tinyint(1)" not-null="false" />
</property>
<property name="houseNumber">
<column name="houseNumber" sql-type="bigint(20)" not-null="false" />
</property>
<property name="complement">
<column name="complement" sql-type="bigint(20)" not-null="false" />
</property>
<property name="obs">
<column name="obs" sql-type="varchar(350)" not-null="false" />
</property>
<bag name="orderPsi" table="ordPsi" cascade="all" inverse="true">
<key column="idOrdPastaI" />
<one-to-many class="ordPsi" />
</bag>
</class>
</hibernate-mapping>
还有cs类:
public partial class order {
public order() { }
public virtual long idOrder { get; set; }
public virtual employee employee { get; set; }
public virtual customer customer { get; set; }
public virtual address address { get; set; }
public virtual System.DateTime date { get; set; }
public virtual System.Nullable<System.DateTime> bakingTime { get; set; }
public virtual string price { get; set; }
public virtual System.Nullable<int> cash { get; set; }
public virtual System.Nullable<int> credit { get; set; }
public virtual System.Nullable<long> houseNumber { get; set; }
public virtual System.Nullable<long> complement { get; set; }
public virtual string obs { get; set; }
public virtual IList<ordPsi> orderPsi { get; set; }
}
这是堆栈跟踪后跟的内部异常:
"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.NullableType.NullSafeSet(IDbCommand cmd, Object value, Int32 index)
at NHibernate.Type.NullableType.NullSafeSet(IDbCommand st, Object value, Int32 index, Boolean[] settable, 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)