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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:52:54+00:00 2026-06-08T02:52:54+00:00

I understand that when all the properties of a mapped component are null in

  • 0

I understand that when all the properties of a mapped component are null in the database, NHibernate will set the component to null. However, in the following case the component is being set to null if the many-to-one item LevelOfInvolvement is null, despite the fact that all the other properties of the component are not null.

Changing the value of the LevelOfInvolvement column in the database will cause the component to be null or not, regardless of the value of the other fields.

Here is the maping in full:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
  <class name="NHS.WebTeam.LPTInvolvementHub.Activity, NHS.WebTeam.LPTInvolvementHub" table="[Activity]" lazy="false" optimistic-lock="version" where="Deleted=0" >
    <id name="ID" type="Int32" column="ID" unsaved-value="0">
      <generator class="hilo">
        <param name="table">NHibernateHiLo</param>
        <param name="column">NextValue</param>
        <param name="max_lo">100</param>
      </generator>
    </id>

    <version name="Version"/>
    <property name="Deleted" />
    <property name="LastUpdateBy" />
    <property name="LastUpdateDate" />

    <many-to-one name="Service" column="ServiceID"></many-to-one>
    <property name="Title"></property>
    <property name="Abstract"></property>
    <property name="ProposedDate"></property>
    <property name="DueDate"></property>
    <property name="ActualDate"></property>
    <property name="Rationale"></property>
    <many-to-one name="PreAssessment" column="PreAssessmentID"></many-to-one>
    <many-to-one name="PostAssessment" column="PostAssessmentID"></many-to-one>

    <component name="InvolvementChecklist">
      <property name="Impact" column="InvolvementChecklist_Impact"></property>
      <property name="RewardsAndRecognition" column="InvolvementChecklist_RewardsAndRecognition"></property>
      <property name="Training" column="InvolvementChecklist_Training"></property>
      <property name="LogisticalIssues" column="InvolvementChecklist_LogisticalIssues"></property>
      <property name="Feedback" column="InvolvementChecklist_Feedback"></property>
      <property name="DueRegard" column="InvolvementChecklist_DueRegard"></property>
      <property name="SupportRequiredFromTheTeam" column="InvolvementChecklist_SupportRequiredFromTheTeam"></property>
      <property name="QualityAssurance" column="InvolvementChecklist_QualityAssurance"></property>
      <property name="NonComplianceReason" column="InvolvementChecklist_NonComplianceReason"></property>
      <many-to-one name="LevelOfInvolvement" column="InvolvementChecklist_LevelOfInvolvementID"></many-to-one>
    </component>

  </class>
</hibernate-mapping>

The code to load the entity is simply:

entity = NHibernateSession.Load(persitentType, id);

I am using NHibernate version 3.3.1

This seems a relatively simple mapping, but I cannot find any reference to others having similar problems.

  • 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-08T02:52:55+00:00Added an answer on June 8, 2026 at 2:52 am

    In addition to returning null if all of the component members are null, I believe NHibernate will also treat a component as null if any non-nullable members are null. By default a <many-to-one> mapping creates a non-nullable member, which I think would cause the behaviour you’re seeing. Try changing the LevelOfInvolement mapping to allow nulls:

    <many-to-one 
        name="LevelOfInvolvement" 
        column="InvolvementChecklist_LevelOfInvolvementID" 
        not-null="false" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm lead to understand that the following grants all proveleges to all databases that
I understand that the browser does all the work in processing client side scripts
I understand that prototype method is shared by all instances of an object in
*edit: I understand that stackoverflow has banned all questions regarding using Microsoft's Visio. I'm
The question says it all. I understand that VC11 is currently only in beta,
We all know of sleep method available in java threads.. I understand that the
First of all, I do understand, that MVC 3 default template's Content folder is
I understand that, in the interest of efficiency, when you query the database you
I have database tables that look like this: A Task can be mapped to
I understand that I can sum the properties of objects in an array in

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.