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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:02:49+00:00 2026-05-26T15:02:49+00:00

Is there a way to with NHibernate to clone an existing object (retrieved through

  • 0

Is there a way to with NHibernate to clone an existing object (retrieved through nhibernate) and perform an insert on it to create a new record, instead of updating the current one.

We are using this to do some kind of temporal versioning and need this kind of behavior.

  • 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-26T15:02:49+00:00Added an answer on May 26, 2026 at 3:02 pm

    I am not aware of anything built into nhibernate that would do what you are after.

    Warning Hack Ahead
    I haven’t tried this so this is just thinking out loud about how nhibernate tracks the objects.

    Depending of the Object graph you could reset the version (if any) and id back to the default specified in the mapping and that should create a clone as it effectivle resets how nhibernate tracks the object and when saved it will have be given a new Id. Also note that any attached mapped objects would also need have the same done to get a deep clone.

    If it was me I would probably put a clone method on the object that returns a new object with a copy of the properties, etc.

    Some other answers on SO suggest using Automapper How to clone objects in NHibernate?

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

Sidebar

Related Questions

Is there a way in NHibernate to check if an object exists in the
Using Castle ActiveRecord / NHibernate: Is there a way you can force an ICriterion
Is there any way to reuse NHibernate components (<component>) in more than one mapping?
Is there a way to ask NHibernate to automatically retry failed connections to a
Is there a way in Fluent NHibernate (or possibly NHibernate in general) to tell
Is there a way in Fluent NHibernate to specify that a foreign key should
I'm wondering if there's any relatively easy way to extend NHibernate to support F#'s
Is there a way in NHibernate to start with an unproxied model var m
Is there a way in fluent nhibernate to map a DateTime to rehydrate my
I am new to JSF and was wondering if there is any way to

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.