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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:47:00+00:00 2026-05-10T20:47:00+00:00

I have a desktop (winforms) application that uses a Firebird database as a data

  • 0

I have a desktop (winforms) application that uses a Firebird database as a data store (in embedded mode) and I use NHibernate for ORM. One of the functions we need to support is to be able to import / export groups of data to/from an external file. Currently, this external file is also a database with the same schema as the main database.

I’ve already got NHibernate set up to look at multiple databases and I can work with two databases at the same time. The problem, however, is copying data between the two databases. I have two copy strategies: (1) copy with all the same IDs for objects [aka import/export] and (2) copy with mostly new IDs [aka duplicate / copy]. I say ‘mostly new’ because there are some lookup items that will always be copied with the same ID.

Copying everything with new IDs is fine, because I’ll just have a ‘CopyForExport’ method that can create copies of everything and not assign new IDs (or wipe out all the IDs in the object tree).

What is the ‘best practices’ way to handle this situation and to copy data between databases while keeping the same IDs?

Clarification: I’m not trying to synchronize two databases, just exporting a subset (user-selectable) or data for transfer to someone else (who will then import the subset of data into their own database).

Further Clarification: I think I’ve isolated the problem down to this: I want to use the ISession.SaveOrUpdate feature of NHibernate, so I set up my entities with an identity generator that isn’t ‘assigned’. However, I have a problem when I want to override the generated identity (for copying data between multiple databases in the same process).

Is there a way to use a Guid.Comb or UUID generator, but be able to sometimes specify my own identifier (for transferring to a different database connection with the same schema).

  • 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. 2026-05-10T20:47:01+00:00Added an answer on May 10, 2026 at 8:47 pm

    I found the answer to my own question: The key is the ISession.Replicate method. This allows you to copy object graphs between data stores and keep the same identifier. To create new identifiers, I think I can use ISession.Merge, but I still have to verify this.

    There are a few caveats though: my test class has a reference to the parent object (many-to-one relationship) and I had to make the class non-lazy-loading to get Replicate to work properly. If I didn’t have it set to eager load (non lazy load I guess), it would only replicate the object and not the parent object (cascade=’all’ in my hbm.xml file).

    The java Hibernate docs have a reference to Replicate(), but the NHibernate documentation doesn’t (section 10.9 in the java docs).

    This makes sense for the Replicate behavior because we want to have fully hydrated entities before transferring them to another data store. What’s weird though is that even with both sessions open (one to each data store), it didn’t think to hydrate the object when I wanted to replicate it.

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

Sidebar

Ask A Question

Stats

  • Questions 123k
  • Answers 123k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Private set on myName means you can only initialize (set)… May 12, 2026 at 1:10 am
  • Editorial Team
    Editorial Team added an answer I like this pattern for programmatically selecting a record on… May 12, 2026 at 1:10 am
  • Editorial Team
    Editorial Team added an answer These statements should do what you want in TSQL. Note,… May 12, 2026 at 1:10 am

Related Questions

People have been developing own solutions to the following problems: Consistent messaging frameworks for
I am currently working on a VB.NET desktop application that uses .mdb (Access) database
I'd like to know what could be the best approach to develop a Windows
Looking for some direction here as I'm running into some migration problems. We have

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.