开发者

Unable to preform a delete on Nhibernate with composite ID

i have add a composite ID to my class. adding new row works fine. but deleting item causes the Excepion:

System.Collections.Generic.KeyNotFoundException was unhandled by user code Message=The given key was not present in the dictionary. Source=mscorlib StackTrace: at System.Collections.Generic.Dictionary`2.get_Item(TKey key) at NHibernate.Engine.StatefulPersistenceContext.RemoveEntity(EntityKey key) in d:\CSharp\NH\nhibernate\src\NHibernate\Engine\StatefulPersistenceContext.cs:line 434 at NHibernate.Action.EntityDeleteAction.Execute() in d:\CSharp\NH\nhibernate\src\NHibernate\Action\EntityDeleteAction.cs:line 87 at NHibernate.Engine.ActionQueue.Execute(IExecutable executable) in d:\CSharp\NH\nhibernate\src\NHibernate\Engine\ActionQueue.cs:line 136 at NHibernate.Engine.ActionQueue.ExecuteActions(IList list) in d:\CSharp\NH\nhibernate\src\NHibernate\Engine\ActionQueue.cs:line 126 at NHibernate.Engine.ActionQueue.ExecuteActions() in d:\CSharp\NH\nhibernate\src\NHibernate\Engine\ActionQueue.cs:line 174 at NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions(IEventSource session) in d:\CSharp\NH\nhibernate\src\NHibernate\Event\Default\AbstractFlushingEventListener.cs:line 241 at NHibernate.Event.Default.DefaultFlushEventListener.OnFlush(FlushEvent event) in d:\CSharp\NH\nhibernate\src\NHibernate\Event\Default\DefaultFlushEventListener.cs:line 19 at NHibernate.Impl.SessionImpl.Flush() in d:\CSharp\NH\nhibernate\src\NHibernate\Impl\SessionImpl.cs:line 1479 at NHibernate.Transaction.AdoTransaction.Commit() in d:\CSharp\NH\nhibernate\src\NHibernate\Transaction\AdoTransaction.cs:line 187 at Spring.Data.NHibernate.HibernateTransactionManager.DoCommit(DefaultTransactionStatus status) in c:_svn\spring-net\tags\spring-net-1.3.1\src\Spring\Spring.Data.NHibernate\Data\NHibernate\HibernateTransactionManager.cs:line 576 开发者_StackOverflowat Spring.Transaction.Support.AbstractPlatformTransactionManager.ProcessCommit(DefaultTransactionStatus status) InnerException:

My mapping file looks like this:

<composite-id>
  <key-many-to-one name="X1" lazy="proxy" class="X1, X1" column="X1" />
  <key-many-to-one name="X2" lazy="false" class="X2, X2" column="X2" />
</composite-id>     

<property name="Id" column="Id" type="int" not-null="true" 
      update="false" insert="false" generated="always"/>
<property name="MinimumAmount" column="MinimumAmount" type="int" not-null="false" />
<property name="MaximumAmount" column="MaximumAmount" type="int" not-null="false" />
<property name="Leverage" column="Leverage" type="int" not-null="false" />

Please help me,

thank you very much, Or.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜