Hibernate version:
NHibernate 1.0.1
Name and version of the database you are using:
SQLServer 2000
Hi, I am trying to implement a set with an order-by attribute
Code:
<set name="Components" order-by="ListIndex" inverse="false" lazy="false" cascade="save-update">
<key column="ComponentsId" />
<one-to-many class="Definition,EAF.Domain.Model" />
</set>
and I want the ListIndex column in the table to be an identity column so that unique values would be generated by the database whenever a new object is inserted. However this gives me the following NH exception:
Quote:
2006-05-23 14:10:34,903 [3160] ERROR NHibernate.Util.ADOExceptionReporter [(null)] - Specified cast is not valid.
2006-05-23 14:10:34,903 [3160] ERROR NHibernate.ADOException [(null)] - Could not save object
System.InvalidCastException: Specified cast is not valid.
at NHibernate.Type.SetType.Wrap(ISessionImplementor session, Object collection)
at NHibernate.Impl.WrapVisitor.ProcessArrayOrNewCollection(Object collection, PersistentCollectionType collectionType)
at NHibernate.Impl.WrapVisitor.ProcessCollection(Object collection, PersistentCollectionType collectionType)
at NHibernate.Impl.AbstractVisitor.ProcessValue(Object value, IType type)
at NHibernate.Impl.WrapVisitor.ProcessValues(Object[] values, IType[] types)
at NHibernate.Impl.SessionImpl.DoSave(Object theObj, Key key, IClassPersister persister, Boolean replicate, Boolean useIdentityColumn, CascadingAction cascadeAction, Object anything)
at NHibernate.Impl.SessionImpl.DoSave(Object obj, Object id, IClassPersister persister, Boolean useIdentityColumn, CascadingAction cascadeAction, Object anything)
at NHibernate.Impl.SessionImpl.SaveWithGeneratedIdentifier(Object obj, CascadingAction action, Object anything)
Does anyone know what I am doing wrong?
Thanks,
Dean.
BTW I cannot use a <list> with an index as I cannot guarantee that the index will be sequential (hence the atempt to use order-by).