From: NHibernate J. <mik...@us...> - 2006-12-21 01:51:27
|
Include Inner Exception on 'Duplicate identifier in table for:' exception msg ------------------------------------------------------------------------------ Key: NH-840 URL: http://jira.nhibernate.org/browse/NH-840 Project: NHibernate Type: Improvement Components: Core Versions: LATER, 1.2.0.Beta3 Reporter: Shane Walters Priority: Minor Using: NHibernate 1.2.Beta2 DotNet 2.0 MS Sql Server 2000 I encountered the following error in 1.2 Beta 2. NHibernate.HibernateException: Duplicate identifier in table for: [Singletree.Core.Domain.Folder#89193] at NHibernate.Persister.Entity.AbstractEntityPersister.Check(Int32 rows, Object id, Int32 tableNumber, IExpectation expectation, IDbCommand statement) at NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id, Object[] fields, Object[] oldFields, Boolean[] includeProperty, Int32 j, Object oldVersion, Object obj, SqlCommandInfo sql, ISessionImplementor session) at NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id, Object[] fields, Int32[] dirtyFields, Boolean hasDirtyCollection, Object[] oldFields, Object oldVersion, Object obj, ISessionImplementor session) at NHibernate.Impl.ScheduledUpdate.Execute() at NHibernate.Impl.SessionImpl.Execute(IExecutable executable) at NHibernate.Impl.SessionImpl.ExecuteAll(IList list) at NHibernate.Impl.SessionImpl.Execute() Took me the better part of a day to figure out that I had a trigger which was affecting the row count. If the TooManyRowsAffectedException is passed to MessageHelper.InfoString, then we get a message that makes it much easier to determine what is happening. In NHibernate.Persister.Entity.AbstractEntityPersister.Check(int rows, object id, int tableNumber, IExpectation expectation, IDbCommand statement) catch (TooManyRowsAffectedException ex) { throw new HibernateException( "Duplicate identifier in table for: " + MessageHelper.InfoString(this, id, Factory),ex); } Now we get a better msg: NHibernate.HibernateException: Duplicate identifier in table for: [Singletree.Webpdm.Core.Domain.Folder#89193] ---> NHibernate.AdoNet.TooManyRowsAffectedException: Unexpected row count: 2; expected: 1 -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.nhibernate.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |