PropertyValueException when trying to persist a new object

Hi,

I am getting this persistent error that I can’t fix:

PropertyValueException: not-null property references a null or transient value AstroLab.Research.LearningLab.AstroComet._AstroLab.Research.LearningLab.AstroSystem.CometsBackref

This error happens inside Session.Save. I create a new comet programatically, and I am trying to use Session.Save to persist it to the database.

Googling the error turns up very little info.

In the database, the two tables look like this:


CREATE TABLE cometList (
	[systemID] [int] NOT NULL,
	[cometID] [int] IDENTITY(1,1) NOT NULL,
	[cometName] [nvarchar](255) NOT NULL,
	[cometSequence] [int] NOT NULL,
	[isLocal] [bit] NULL
);
CREATE TABLE systemList (
	[learningID] [int] NOT NULL,
	[systemID] [int] IDENTITY(1,1) NOT NULL,
	[systemSequence] [int] NOT NULL,
	[systemName] [nvarchar](255) NULL,
	[systemDateTime] [datetime2](0) NULL,
);

In the cometList table, the systemID column is a foreign key(systemList).

Inside my .NetCore Web App, my AstroComet XML mapping looks like this:

<?xml version="1.0" encoding="utf-8" ?>

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
    schema="dbo" assembly="AstroLab.Learn" namespace="AstroLab.Research.LearningLab">
  <class name="AstroComet" table="cometList">
    <id name="Id" column="cometID">
      <generator class="identity" />
    </id>

    <many-to-one name="System" class="AstroSystem" column="systemID" update="false" insert="false" />
    <property name="Sequence" column="cometSequence" update="false" insert="false" />

    <property name="Title" column="cometName" />

    <property name="IsLocal" column="isLocal"/>

  </class>
</hibernate-mapping>

And the AstroSystem mapping looks like this:

<?xml version="1.0" encoding="utf-8" ?>

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
    schema="dbo" assembly="AstroLab.Learn" namespace="AstroLab.Research.LearningLab">

  <class name="AstroSystem" table="systemList">
    <id name="Id" column="systemID">
      <generator class="identity" />
    </id>

    <many-to-one name="LearningLab" class="LearningLab" column="learningID" insert="false" update="false" />
    <property name="Sequence" column="systemSequence" insert="false" update="false"/>

    <property name="Title" column="systemName" />
    <property name="ResearchDate" column="systemDateTime" />


    <list name="Comets" inverse="false" cascade="all">
      <key column="systemID" not-null="true" />
      <index column="cometSequence" />
      <one-to-many class="AstroComet" />
    </list>


  </class>
</hibernate-mapping>

I’ve searched, tried a few things, rewrote some of the code, but it always gives me this error no matter how I try to fix it.

If anyone has any experience with an error like this, please let me know.

Thanks!

This forum is for Hibernate, the Java implementation. For questions about NHibernate, please use the forums as listed on the https://nhibernate.info website like e.g. https://groups.google.com/g/nhusers