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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:02:33+00:00 2026-05-13T18:02:33+00:00

I have a parent table, Orders and a child table, [Order Details], I have

  • 0

I have a parent table, Orders and a child table, [Order Details], I have setup the fluent mappings as –

(In the parent Order class)

HasMany<OrderDetails>
(x => x.Details).KeyColumn("OrderId").Cascade.AllDeleteOrphan().Inverse();

(In the child [Order Details] class)

References(x => x.ParentOrder).Column("OrderId").Not.Nullable().Cascade.None();

I am trying to delete the parent object by calling –

session.Delete(parent);
session.Flush();

this works only when there is only one child record, if there are more than one child records, the children get deleted, but the parent doesn’t!!! And I get the dreaded – Unexpected row count error.

I am sure that this is something silly that I am doing, but trawling through the web hasn’t turned up anything.

Thanks

  • 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-13T18:02:33+00:00Added an answer on May 13, 2026 at 6:02 pm

    Ok, I figured this out, it was me being stupid, but then the answer might help someone else, so here goes.

    The [Order Details] table has a composite key and is linked to the both the [Orders] and [Products] table (Yes, this is the Northwind database that I am working with). For my test, I hadn’t mapped my Products table, and had marked up my [Order Details] class with a single primary key, rather than a composite key. So, when Nhibernate deleted rows based on the key, it expects to see only one row being deleted whereas multiple existed on the database. Which is why I was getting the error. Rather clever of Nhibernate.

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

Sidebar

Related Questions

If I have a parent table and a child table where there can be
I have a simple parent/child tables. Contract is the parent table. Each contract can
I have db table with parent child relationship as: NodeId NodeName ParentId ------------------------------ 1
I have a table which defines a child-parent relationship between nodes: CREATE TABLE node
I have a parent/child relation table, many to many parentid int not null childid
I have a parent-child relationship, such as Order to Order Item, which I have
The MSDN claims that the order is : Child table: delete records. Parent table:
I have two tables a parent and a child table. The child table has
I have a table which keeps parent-child-relations between items. Those can be changed over
I have a parent table called 'Website' which holds records about websites. I have

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.