I'm gradually working my way through mapping a legacy database to NHibernate. After mapping >40 tables I think I've found one that's unmappable - unless someone here can help?
1) It doesn't have a PK defined 2) The natural PK would be a composite PK made up of all 5 columns 3) 4 of the columns are nullable
Because the candidate composite PK columns are nullable, I believe this is impossible to map in NHibernate - am I correct?
When I map the entity and attempt to query it, I've been getting errors like:
[1764] Index was out of range. Must be non-negative and less than the size of the collection. [1764] Parameter name: index [1764] System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. [1764] Parameter name: index [1764] at System.Collections.ArrayList.get_Item(Int32 index) [1764] at Oracle.DataAccess.Client.OracleParameterCollection.GetParameter(Int32 index) [1764] at System.Data.Common.DbParameterCollection.System.Collections.IList.get_Item(Int32 index) [1764] at NHibernate.Type.Int32Type.Set(IDbCommand rs, Object value, Int32 index) [1764] at NHibernate.Type.NullableType.NullSafeSet(IDbCommand cmd, Object value, Int32 index) [1764] at NHibernate.Type.NullableType.NullSafeSet(IDbCommand st, Object value, Int32 index, ISessionImplementor session) [1764] at NHibernate.Type.ComponentType.NullSafeSet(IDbCommand st, Object value, Int32 begin, ISessionImplementor session) [1764] at NHibernate.Persister.Entity.AbstractEntityPersister.Dehydrate(Object id, Object[] fields, Object rowId, Boolean[] includeProperty, Boolean[][] includeColumns, Int32 table, IDbCommand statement, ISessionImplementor session, Int32 index) [1764] at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object id, Object[] fields, Boolean[] notNull, Int32 j, SqlCommandInfo sql, Object obj, ISessionImplementor session) [1764] at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object id, Object[] fields, Object obj, ISessionImplementor session) [1764] at NHibernate.Action.EntityInsertAction.Execute() [1764] at NHibernate.Engine.ActionQueue.Execute(IExecutable executable) [1764] at NHibernate.Engine.ActionQueue.ExecuteActions(IList list) [1764] at NHibernate.Engine.ActionQueue.ExecuteActions() [1764] at NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions(IEventSource session) [1764] at NHibernate.Event.Default.DefaultFlushEventListener.OnFlush(FlushEvent event) [1764] at NHibernate.Impl.SessionImpl.Flush() [1764] at NHibernate.Transaction.AdoTransaction.Commit()
|