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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:09:03+00:00 2026-06-13T02:09:03+00:00

I am getting a weird error in NHibernate (v3.3), when trying to persist an

  • 0

I am getting a weird error in NHibernate (v3.3), when trying to persist an entity with a manually generated ID:

Unable to determine if {Entity} with assigned identifier {Id} is transient or detached; querying the database.
Use explicit Save() or Update() in session to prevent this.

But the problem is, I am using Save instead of SaveOrUpdate. What could be the problem?

  • 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-06-13T02:09:04+00:00Added an answer on June 13, 2026 at 2:09 am

    It turned out that my problem was actually happening while saving the parent entity, containing child entities in a one-to-many relation:

    <class xmlns="urn:nhibernate-mapping-2.2" name="ParentTable" table="ParentTable">
    
        <id name="ManuallyAssignedId">
          <generator class="assigned" />
        </id>
    
        <!- child table also has a manually assigned id -->
        <bag cascade="all" inverse="true" name="ChildTable">
          <key>
            <column name="ParentTable_id"/>
          </key>
          <one-to-many class="ChildTable" />
        </bag>
    
    </class>  
    

    In other words, a call to Save on the parent entity caused a SaveOrUpdate on child entities, which NHibernate was complaining about.

    When I realized that, I quickly found this StackOverflow thread: How to save a child with assigned id in nhibernate, which has two great suggestions:

    1. Create and map a Version or Timestamp column – if it’s null, NHibernate will know it needs to persist the entity, or

    2. Attach a custom Interceptor to a session (or session factory) and use a custom private field to keep track of whether the entity needs to be persisted.

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

Sidebar

Related Questions

I am getting a weird error when trying to use a Java map in
I'm trying to implement adaptive payments but keep getting this weird error. Here's the
I am trying to build my project and I am getting a weird error
I am trying to get a script working, but I'm getting this weird error.
For almost a week i'm getting this weird error when i'm trying to run
I am getting a weird error when I run an MSI generated by BTSTask:
After uninstalling ActiveState I've been getting this weird error when trying to execute perl
Trying to install memcached-northscale and getting a weird error. Any help would be appreciated.
I'm getting a weird error, when initializing my deque or vector. I'm using QtCreator
I am getting this weird error while running cucumber test: ERROR Mongo::OperationFailure: Database command

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.