Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8661971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:37:29+00:00 2026-06-12T16:37:29+00:00

I have the following Nhibernate XML file, edited to the core bits: <?xml version=1.0

  • 0

I have the following Nhibernate XML file, edited to the core bits:

<?xml version="1.0" encoding="utf-8"?>
   <hibernate-mapping assembly="TTP.DAO" namespace="TTP.DAO" xmlns="urn:nhibernate-mapping-2.2">
<class name="InitialProcessSetup" table="InitialProcessSetup" lazy="true" >
    <id name="SetupID" column="setupID" unsaved-value="0" type="System.Int32">
        <generator class="identity"/>
    </id>
    <property name="DateCreated" column="DateCreated" />
    <many-to-one class="StoredUser" name="CreatedBy" column="CreatedBy" cascade="all-delete-orphan" not-null="true"/>
    <property name="OriginalDeadline" column="Deadline" />
    <property name="Detail" column="Detail" />
    <bag name="Subjects" table="InitialProcessSetupRatingSubject" inverse="true" cascade="all-delete-orphan">
        <key column="SetupId" not-null="true" />
        <many-to-many column="SubjectStoredUserId" class="StoredUser" />
    </bag>
    <bag name="Reviewers" table="InitialProcessSetupReviewer" cascade="all-delete-orphan">
        <key column="SetupId" not-null="true" />
        <many-to-many column="ReviewerStoredUserId" class="StoredUser" />
    </bag>
    <bag name="Invitations" cascade="all-delete-orphan">
        <key column="Setup" not-null="true"/>
        <one-to-many class="ProcessInvitation" />
    </bag>
</class>

I populate a new instance of the class indicated in the above mapping and save via GenericDAO().SaveOrUpdate(setup); and it saves the main object details but does not store the bit.

On the class Subjects is defined as a virtual property that returns IList-StoredUser. The class constructor sets this property to a new List-StoredUser-().

The table indicated by the Subjects bag element is a pure mapping table that is it has a SetupID and StoredUserID column and that’s it.

I add using a StoredUser to my derived StoredUserDAO() to the Subjects lists before saving. After the call to SaveOrUpdate() I also call Flush() as well.

In my database (SQL Server 2008R2) The main setup data is saved and the stored user I added to the Subjects list property is also saved it’s just the mapping table does not get the setupID/StoredUserID added.

I’m a bit of a noob with Nhibernate and this is an existing project.
Any help ideas on what is wrong would be most appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T16:37:30+00:00Added an answer on June 12, 2026 at 4:37 pm

    You have set inverse=”true” for the Subjects collection. This implies that for NHibernate to create a record in the relation table, it must be the StoredUser that references the InitialProcessSetup.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following mapping file: <?xml version=1.0 encoding=utf-8 ?> <hibernate-mapping xmlns=urn:nhibernate-mapping-2.2 assembly=Project1.Accounts namespace=Project1.Core.Domain>
I have the following configuration file for NHibernate : <?xml version=1.0 encoding=utf-8 ?> <hibernate-configuration
I have the following file Log4net.config in my bin directory: <?xml version=1.0 encoding=utf-8 ?>
I have JRE 1.6 and am using the following hibernate.cfg.xml file. I am always
I have an ApplicationContext.xml file with the following node: <context:property-placeholder location=classpath:hibernate.properties, classpath:pathConfiguration.properties /> It
I have the following mapping for the birth date in the hbm.xml file <property
I have the following configuration file in a application console: <?xml version=1.0?> <configuration> <configSections>
I have the following class defined in my mapping XML file: <class name=com.data.StateRefData table=STATE_REF>
I have a very simple Mapping I'm trying to do. I'm following the NHibernate
I have the following mapping: <hibernate-mapping package=server.modules.stats.data> <class name=User table=user> <id name=id> <generator class=native></generator>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.