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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:49:15+00:00 2026-05-15T16:49:15+00:00

I am having a problem saving the Parent object which contains multiple children. The

  • 0

I am having a problem saving the Parent object which contains multiple children.

The Model Classes are as follows:

public class Driver
{
   private IList<CitationEvent> _CitationEvents = new List<CitationEvent>(1);
}


public class CitationEvent
{
  public virtual Driver Driver { get; set; }
}

XML Mapping in Driver.hbm.xml

<bag name="_CitationEvents" access="field" cascade="all-delete-orphan"  inverse="true">
      <key column="DRIVER_ID" />
      <one-to-many class="CitationEvent" />
</bag>

XML Mapping in CitationEvent.hbm.xml

<many-to-one  name="Driver" class="Driver" column="DRIVER_ID" cascade="none"/>

When I try to save driver, NHibernate throws following exception "Nullable object must have a value"

The code which saves it:

ITransaction transaction = session.BeginTransaction(IsolationLevel.ReadCommitted);

try
{
  session.Save(driver);
  transaction.Commit();
}
catch (Exception ex)
{
   transaction.Rollback();
}

One more observation about the problem:
When I try to just save Driver with empty list _CitationEvents it does not give me this exception.

  • 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-15T16:49:16+00:00Added an answer on May 15, 2026 at 4:49 pm

    This isn’t an NHibernate specific error. The probable cause is that you have a nullable property in one of your classes that you are attempting to cast to a non-nullable type. This exception is thrown by the .NET Framework when attempting to access the Value property of a nullable type that does not have a Value.

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

Sidebar

Related Questions

I'm having a problem saving/loading an ArrayList<HashMap<String, Object>> across Android versions. I've been searching
I am having a problem saving a Domain object. Below is my Controller code:
I am having problem saving additional information about each user automatically when a new
I am having problems while saving a pre-persisted JDO object in google-app-engine data store.
I am having problem with drawing multiple lines during repaint. The code is as
In this question I was having problem with saving objects that had foreign keys
I'm having a hard time figuring this validation problem. I have one parent domain
I have a model which uses acts-as-tree. For example: class CartoonCharacter < ActiveRecord::Base acts_as_tree
I'm having a problem saving a string file with NSSavePanel after sandboxing the app
I'm having a strange problem saving data with cakePHP. I'll explain as I go.

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.