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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:45:51+00:00 2026-05-27T01:45:51+00:00

Given optimistic concurrency using a version property and a json rest-service with a client

  • 0

Given optimistic concurrency using a version property and a json rest-service with a client that returns changesets consisting of the Id, Version and changed properties only, how can I update my server-side entity?

What I wanted to do was deserialize my json into a detatched entity and then use the ISession.Merge method to update my entity. However, my detached entity will have null-values for a lot of properties, and my entity will be updated with all of these if I call merge, which is not what I want. If there is a way to tell merge to ignore properties that are null and keep any corresponding non-null values from the persisted entity that would solve my problem.

If there is no way to configure the behaviour for merge, I could of course get the persisted entity and implement my own merging method using reflection. The problem with this approach is that it requires that I first query the db for the entity and then update it, whereas the merge method should do this as one operation unless I am mistaken.

You might ask why I want to pass only changesets instead of the complete entity. It is because it allows me to send minimal data and it also indicates explicity what the user is trying to change, which I can use for testing that users rights.

If it isn’t possible to do this within the bounds of nhibernate, how would you proceed?

  • 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-27T01:45:51+00:00Added an answer on May 27, 2026 at 1:45 am

    I ended up using the WCF Web API for my application. I’m using a custom media formatter, wrapping Json.NET. This allows me to deserialize into generics and derived types, which is pretty awesome, and very usefull.

    I have a ChangeSet object which has a few properties, the most important of which is a name-value Dictionary. With this setup I could define service operations taking ChangeSet objects. However I had to explicitly remove the XmlMediaFormatter. It was throwing errors, since it would not be able to deserialize such complex objects.

    After checking the users rights to change these properties, I fetch the object from the repository, update properties from the change-set, using reflection, and save it back to the repository.

    Works beautifully if I’m being honest. 🙂

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

Sidebar

Related Questions

we are using hibernate with optimistic locking. All our entities have the @version annotation.
Given this: $ids = ''; I just realized that this: $single = $ids ==
I've introduced a TransactionService that I use in my controllers to execute optimistic transactions.
Given a tree, how to find the centre node in the tree so that
Given that a ThreadLocal variable holds different values for different threads, is it possible
Given a class that keeps a registry of its Objects: class Person(object): __registry =
Given a graph of n nodes that are all interconnected on a coordinate plane,
Given long long int x, y; , I want a function that can compare
Given that I have the array Let Sum be 16 dintptr = { 0
Given a specific DateTime value, how do I display relative time, like: 2 hours

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.