Okay, I got it to work. The user field in the requestNote mapping is a
reserved word. Once i rename that field and it works.

However, I had to do a requestService.Save first that way a requestID
will be generated and then I can pass it to the requestNote and save
it again.

If there is a quicker way, do please tell.

On Dec 15, 10:35 pm, Oskar Berggren <[email protected]> wrote:
> If I've read your mappings correctly it seems that should work.
> However, I wonder what requestService.Save() does. If if just calls
> ISession.Save(), you don't need to do that on an existing request if
> it's already part of the current session. Does it do something else?
>
> /Oskar
>
> 2011/12/15 aric <[email protected]>:
>
>
>
>
>
>
>
> > I been scratching my head on this one for awhile.. any help would be
> > appreciated.
>
> > I have two tables (request and requestNotes) i am saving a request
> > first then once i have the RequestID from the request then I save the
> > notes into the requetNotes table and pass over the requestID but i
> > can't get the notes to save.
>
> > Here is my Mapping
>
> >        <class name="CUS_SCU_Request" table="CUS_SCU_Request">
> >                <id name="RequestID" column="RequestID" type="int">
> >      <generator class="identity" />
> >                </id>
>
> >    <property name="QueueInstanceID" type="Guid" not-null="true" />
> >                <property name="RequestDate" type="DateTime" not-null="true" 
> > />
>
> >    <many-to-one cascade="none"
>
> > class="Jenzabar.Portal.Framework.NHibernateFWK.Couplers.PortalUserCoupler,
> > Jenzabar.Portal.Framework"
> >             name="SubmittedUser"
> >             column="RequestBy"
> >             not-null="true"></many-to-one>
>
> >                <property name="AssignTo" type="Guid" not-null="false" />
> >                <property name="Subject" type="String" not-null="true" />
>
> >                <bag name="Notes" table="CUS_SCU_RequestNotes" cascade="all">
> >                        <key column="RequestID" />
> >                        <one-to-many class="RequestNote" />
> >                </bag>
> >        </class>
>
> >  <class name="RequestNote" table="CUS_SCU_RequestNotes">
> >    <id name="NoteID" column="RequestNoteID" type="int">
> >      <generator class="identity" />
> >    </id>
>
> >    <property name="RequestID" column="RequestID" type="int" />
> >    <property name="DateEntered" column="DateTime" type="DateTime" not-
> > null="false" />
>
> >    <many-to-one cascade="none"
>
> > class="Jenzabar.Portal.Framework.NHibernateFWK.Couplers.PortalUserCoupler,
> > Jenzabar.Portal.Framework"
> >             name="User"
> >             column="User"
> >             not-null="true"></many-to-one>
>
> >    <property name="Notes" column="Notes" type="String" not-
> > null="false" />
> >    <property name="StatusID" column="StatusID" type="int" not-
> > null="false" />
> >  </class>
>
> > Inserting a REQUEST
>
> >            RequestMapperService requestService = new
> > RequestMapperService();
> >            CUS_SCU_Request request = new CUS_SCU_Request();
>
> >            request.QueueInstanceID = QIID;
> >            request.RequestDate = DateTime.Now;
> >            request.SubmittedUser = new
> > PortalUserCoupler(PortalUser.Current);
> >            request.Subject = txtSubject.Text;
>
> >            requestService.Save(request);
>
> > Inserting a NOTE
>
> >            RequestNote note = new RequestNote();
>
> >            note.RequestID = request.RequestID;
> >            note.DateEntered = DateTime.Now;
> >            note.User = new PortalUserCoupler(PortalUser.Current);
> >            note.Notes = txtDescription.Text;
> >            note.StatusID = 1;
>
> >            request.Notes.Add(note);
> >            requestService.Save(request);
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "nhusers" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to 
> > [email protected].
> > For more options, visit this group 
> > athttp://groups.google.com/group/nhusers?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to