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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:54:12+00:00 2026-05-26T12:54:12+00:00

I have a project by NHibernate implementation and using Lazy Loading. I have two

  • 0

I have a project by NHibernate implementation and using Lazy Loading.
I have two class in this project : Person and Family.
Relation between Those two is aggregation, is mean a Person has a list of Person.
Maping is :

  <class name="Person" table="Person_Person" >

    <id name="Id" type="Int64" unsaved-value="0">
      <generator class="native" />
    </id>

    <bag name="Families" inverse="true" table="Person_Family" cascade="all-delete-orphan" >
      <key column="Person_id_fk"/>
      <one-to-many class="Domain.Entities.Family,Domain.Entities"/>
    </bag>

  </class>

In this project, I Get a person by ID then remove a family of families person.

Person person = SessionInstance.Get<Person>(id);
foreach (Family fam in person.Families)
    if (fam.Name == "Jaun")
        SessionInstance.Delete(fam);

The family not deleted, Because throw a exception by this message :
deleted object would be re-saved by cascade (remove deleted object from associations)[Domain.Entities.Family#167]

How can i delete a family of person?

  • 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-26T12:54:13+00:00Added an answer on May 26, 2026 at 12:54 pm

    Basically what NHibernate is complaining about is that you are explicitly telling it to delete a record for the Family, then when you re-save the Person the Family will be put right back in place, because the Person still has a reference to it in its list of Families.

    Instead, NHibernate is telling you to deal with this relationship in the object-oriented manner that NHibernate allows you to use. Simply remove the reference to the “Jaun” family from the Person.Families list, then persist the Person. When you do this, NHibernate will remove the relationship between that Family and that Person. If the Family is now no longer referenced by anything else, since you have set the Cascade property to “all-delete-orphan”, the “Jaun” Family record will be deleted completely from the DB.

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

Sidebar

Related Questions

I have just restarted a project in which I am using NHibernate. The project
In my project I am using NHibernate/FluentNHibernate, and I am working with two entities,
I have a project where I'm using NHibernate to handle bindings to the database.
I have a project using NHibernate (version 2.2). For upgrade to NHibernate 3.2 ,
there is a project using nhibernate v2.1 and i have been wondering whether v3
I'm looking into a project using nhibernate and I have a question on how
I have an MVC3 project using nHibernate, Rhino and Castle. I finally got all
Normally when using Nhibernate I have models in the Nhibernate project, then they are
I'm working on setting up NHibernate for a project and I have a few
Background Fluent NHibernate 1.1 (with a repository implementation using LINQ to NHibernate) in an

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.