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 208961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:52:22+00:00 2026-05-11T17:52:22+00:00

I am trying to save a record which has a many-to-one property mapping. I

  • 0

I am trying to save a record which has a many-to-one property mapping. I attempt to assign a newly created parent object here (or use an existing, but that works fine) but I get an error when it tries to add the ID of the parent object to the child’s table. Saying it cannot add NULL to the table, which is true, but I thought nHibernate was clever enough to save the parent object first, even if I am adding the child.

Mappings:

Child:

 <many-to-one name="parent" class="ParentClass" column="parentID" cascade="all"/>

Parent:

<bag name="DataList" table="ChildTable" lazy="false" inverse="true" cascade="all-delete-orphan">
      <key column="parentID" />
      <one-to-many class="ChildClass" />
    </bag>

Basically, Is this something nHibernate can do?

  • 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-05-11T17:52:22+00:00Added an answer on May 11, 2026 at 5:52 pm

    I can’t see your parent mapping, but I’d wager if you have inverse = true and cascading turned on there for a set of child objects, and you allow nulls in the parentID column of your child object, when the parent got around to saving it would update the child object properly.

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

Sidebar

Related Questions

I'm trying to save a record which doesn't have one field set -- which
I am trying to save a custom object as a user setting in a
How do I save a large collection with NHibernate which has elements that surpass
I have a table called order which has many order_items , each order_items is
I am trying to provide undo functionality after a record has been deleted. To
Basically I'm trying to save a Django model which contains an ImageField , and
I have a couple of domain objects which I am trying to save using
I am trying to work out the best way to save a belongs_to record
I'm trying to query a table, fetch all records, and save the result as
im trying to save a row in my settings table, it works all fine

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.