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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:13:00+00:00 2026-05-20T03:13:00+00:00

I’ve got kind of dumbed-down entities coming in on an http request that I’m

  • 0

I’ve got kind of “dumbed-down” entities coming in on an http request that I’m looking to save as simply as possible. These entities have all of their own data, but none regarding the associated entities (users, etc…).

Using Session.Merge seems to be doing a good enough job getting the detached entity back into the session, and I’m not losing any of the associated collections. But anything associated via a “References” relationship disappears when I save the merged entity. I don’t think this is cascading behavior (I have cascade=none defined by convention).

Is there any way I can modify the merge behavior (via configuration or otherwise) so that I can merge these incomplete entities without breaking associations? I’m hoping to get rid of a lot of the “roll your own” merge code that is currently there.

I’m using fluent nhibernate for mapping if that changes available options.

edit:

I ended up exposing merge through a base repository but making the method virtual so I could deal with this type of situation in specific implementations as needed. Seems to work well enough.

  • 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-20T03:13:01+00:00Added an answer on May 20, 2026 at 3:13 am

    NHibernate’s “Merge” method does something a little different than what you think, I think. It basically attaches the object and its children to the session, replacing any copy of the same record that’s already there. What you need is something that acts more like an SVN merge, taking your changes from the object graph you pass in, and integrating them into the existing object graph. This is beyond NH’s capabilities.

    Sorry to say, but I think you’re gonna be stuck rolling your own on this one. Making NH do something like this would require configuring a lot of rules about things like “when is a null reference an actual change, and when should it be ignored”, which can even change from case to case.

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

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a small JavaScript validation script that validates inputs based on Regex. I
I am currently running into a problem where an element is coming back from
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.