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

  • Home
  • SEARCH
  • 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 955547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:23:50+00:00 2026-05-16T00:23:50+00:00

the database has two table,one is mb_user table and other is mb_comment table。A user

  • 0

the database has two table,one is mb_user table and other is mb_comment table。A user have some comments.When I insert a comment into mb_comment ,the comment_user_id of mb_comment is null.I can’t save value of comment_user_id.Please help me!

Map file
mb_user Map file

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="MiserBlogData" namespace="MiserBlogData.Entities" default-lazy="false">
  <class name="A_Person" table="mb_user" discriminator-value="0">
    <id name="Id" column ="user_id" >
      <generator class ="native"/>
    </id>
    <discriminator column="user_role" type="int" />
    <property name="State" column="user_state" />
    <property name ="Name" column="user_name" />
    <property name ="Pwd" column="user_pwd" />
    <property name ="CDate" column="user_cdate" />
    <property name ="UDate" column="user_udate" />
    <property name ="Role" column="user_role" />
    <property name ="Face" column="user_face" />
    <bag name="CommentList"  >
      <key column="comment_user_id" foreign-key="FK_PersonComment" />
      <one-to-many class="Comment" />
    </bag>
  </class>
</hibernate-mapping>

mb_comment Map file

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="MiserBlogData" namespace="MiserBlogData.Entities">
  <class name ="Comment" table="mb_comment">
    <id name="Id" column ="comment_id">
      <generator class ="native"/>
    </id>
    <property name ="ArticleId" column="comment_article_id" />
    <property name ="Content" column="comment_content" />
    <property name ="State" column="comment_state" />
    <property name ="CDate" column="comment_cdate" />

    <many-to-one name="Person"  column="comment_user_id" class="A_Person" not-null="true" foreign-key="FK_PersonComment"   />
  </class>
</hibernate-mapping>

C# code

    protected ISession _session = NHibernateHelper.GetCurrentSession();

    public virtual object Save<T>(T obj) where T : class
    {
        return _session.Save(obj);
    }

error :not-null property references a null or transient valueMiserBlogData.Entities.Comment.Person

I know,if I remove not-null=”true” in mb_comment file ,system is good.But comment_user_id column is null.How to solve?

  • 1 1 Answer
  • 1 View
  • 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-16T00:23:51+00:00Added an answer on May 16, 2026 at 12:23 am

    You should assign the property Person on your Comment to a valid A_Person instance. Then NHibernate will know which user id to write in the table.

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

Sidebar

Related Questions

I have two tables in a database. Table questions , has two columns, ID
Background: I have a database table which is for received_msgs The table has two
I am implementing a class that resembles a typical database table: has named columns
I have two similar queries on same table and same where condition but different
I have a mysql database with 4 different databases. 1 of the databases has
I have two CSV files with a common column and I want to Join
Our company has 4 business entities, so I have created 4 different databases for
another database structuring question, hope you guys dont mind :D i am having this
I read that Oracle maintains row versions to deal with concurrency. I want to
Using Linq, trying to select all records not in my local set fails: var

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.