Hi people, i have a problem with this mapping file that do not allow me to save un object, my mapping file is this:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0"> <class name="Middleware.Exercises.SubmitExercise, Middleware" table="Elearn_SubmitExercises"> <id name="SubmitExerciseID" column="SubmitExerciseID" type="Int32" length="4" unsaved-value="0"> <generator class="identity"/> </id> <property name="DateStart" column="DateStart" type="DateTime" length="8"/> <property name="DateFinish" column="DateFinish" type="DateTime" length="8"/> <list name="SubmitQuestions" table="Elearn_SubmitQuestions" > <key column="SubmitQuestionID"/> <index column="Indice"/> <one-to-many class="Middleware.Exercises.SubmitQuestion, Middleware"/> </list> </class> </hibernate-mapping>
that maps de class submitExercise that have a list of submited questions.
I have 2 tables one submiteExercises and another SubmitQuestions, this last one have this fields:
SubmitQuestionID int (Primary key and identity) SubmitExerciseID int QuestionID int Indice int Grade decimal
and my submitexercise table have this fields:
SubmitExerciseID int DateStart datetime 8 1 DateFinish datetime 8 1
my problem is when, that first when i log in as a teacher i create a record for each student in table submitexercise, and than when i log in as student and try to solve de exercise i have got this error:
could not synchronize database state with session Exception: NHibernate.TransientObjectException Message: object references an unsaved transient instance - save the transient instance before flushing: SubmitQuestion Source: NHibernate at NHibernate.Impl.SessionImpl.ThrowTransientObjectException(Object obj) at NHibernate.Impl.SessionImpl.GetEntityIdentifierIfNotUnsaved(Object obj) at NHibernate.Type.ManyToOneType.NullSafeSet(IDbCommand cmd, Object value, Int32 index, ISessionImplementor session) at NHibernate.Collection.CollectionPersister.WriteElement(IDbCommand st, Object elt, Boolean writeOrder, ISessionImplementor session) at NHibernate.Collection.List.WriteTo(IDbCommand st, CollectionPersister persister, Object entry, Int32 i, Boolean writeOrder) at NHibernate.Collection.CollectionPersister.InsertRows(PersistentCollection collection, Object id, ISessionImplementor session) at NHibernate.Impl.ScheduledCollectionUpdate.Execute() at NHibernate.Impl.SessionImpl.ExecuteAll(ICollection coll) at NHibernate.Impl.SessionImpl.Execute()
Please someone help me, this is the only problem i have to finish my project.
Thanks
Hugo Alves
|