Sunday, 15 August 2010

Error updating in nHibernate: "Index was out of range." -


On an update called FHH, I get the following error:

Should be non-negotiable and less than the size of the collection. \ R \ nParameter's Name: Index

This is probably some bad mapping, what's the best way to diagnose it? I really want to see the update which is trying to issue it.

Here is the code:

  Public Zero Update & lt; T & gt; {Ie.Update (value, tx); (ienumerable & lt; T & gt; value) {foreach (var value in values) {{var tx = session.BeginTransaction ()); Tx.Commit (); If you can post your mapping this will help, but this usually happens when you have a parent & gt; Includes a mapping for the foreign key column for the same relationship in the hair relationship using the flint  context  syntax  and .  

The result is, mapping en hibernate twice in the area and as a result of the error that you are experiencing.

When you use the reference syntax, nHibernate takes care of the foreign key column for you, however, if you still want it in your object then just change the definition of your mapping in that area < Code> to read () There is an option to treat the problem if you do not need it, then you can completely remove it from your mapping definition.

To answer strictly to ask questions (to diagnose yourself) I suggest 2 options:

  • Free option - Install log4net and configure the nHibernate to output the logger component to all your SQL statements. In this way you will see abusive statements in log files and will be able to separate the problem.
  • Cost Options - Downloads and Trials / Buy by Rhino Hibernating It will give you full details of all the SQL statements sent to the database by nHibernate, will be completed with recommendations or warnings for improvements, and all a good In GUI

No comments:

Post a Comment