Nhibernate的一个问题

出现了这个问题 ,找了很久弄好,后来别人提供了一个链接

http://codeverity.com/timweaver/nhibernate-invalid-index-for-this-sqlparametercollection/ 

 

 Here's my mapping file: [I swear I'm switching to attributes first chance I get, but I learned the Xml mapping and time doesn't permit the change at this point]

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
    schema="TestDB.dbo"    
    namespace="Domain.Foo"
    >
  <class name="Domain.Foo.ProfileP, Domain" table="ProfileP" lazy="false" >
    <id name="ID" column="ID" type="Int32" unsaved-value="0">
      <generator class="native" />
    </id>
    <property name="ProfileId" column="profileId" type="Int32" />
    <property name="PaymentId" column="paymentId"   type="Int32"  insert="false" update="false" />
    <property name="Status" column="status"    type="string" length="10" />
    <many-to-one name="PaymentS" class="Domain.Foo.Sub, Domain" column="paymentId" cascade="save-update" not-null="true"  />
  </class>
</hibernate-mapping>

 

The problem is the line in red. The PaymentID is the ID value of the PaymentS class in the Domain.Foo.Sub namespace. So, NHibernate already knew the ID value and was using it in the update/save queries. In effect it was declared twice in the mapping file: once explicitly and once implicitly via the many-to-one relationship. The fix was to add insert="false" and update="false" to the paymentId property.

I ended up purchasing the NHibernate in Action book via the early access program. So far I am pleased with the purchase. The book has shed light on a lot of pieces of information that were unclear to me. Getting concise and complete information on NHibernate seems to be a lot harder than I would have thought.

转载于:https://www.cnblogs.com/SumYang/archive/2011/04/18/2019488.html

  • 0
    点赞
  • 0
    收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值