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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:54:23+00:00 2026-05-11T01:54:23+00:00

I have set the FlushMode property on an NHibernate session to FlushMode.Never, but when

  • 0

I have set the FlushMode property on an NHibernate session to FlushMode.Never, but when I call session.Save(User), a call gets made to the database anyway. Is this how this is supposed to work? I would think that it shouldn’t do an insert until I call Flush().

Edit: I found the issue, I changed the primary key to guid and it worked. Are there any other types (i.e. no guid primary key) that will work? I would rather have a number instead of a guid…

  • 1 1 Answer
  • 1 View
  • 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-11T01:54:23+00:00Added an answer on May 11, 2026 at 1:54 am

    You were using a native generator, right?

    The problem with this lies in the fact that, since it’s the DB that generates the ID, NHibernate needs a round trip to fetch it. As an example, for Server’s identity fields the actual INSERT statement must be executed before SCOPE_IDENTITY() returns a valid key. And the only way to perform this operation safely is by flushing the session.

    As an alternative to guids and identity you can try the ‘increment’ generator to see if it fits your needs: http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/mapping.html#mapping-declaration-id-generator

    You should be aware that this approach won’t be feasible if you cluster your app, or you have some other process or application inserting into the same table.

    PS: for further reading try http://unhandled-exceptions.com/blog/index.php/2008/12/11/on-choosing-an-identity-type/

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

Sidebar

Related Questions

I have set FlushModeType to COMMIT , but right after em.persist() call, the INSERT
I have set of flat files (114 files) each file is named with database
I have set the AutoSize property of the form to True and I have
I have set onItemClicklistener on my custom list view but onItemClicklistener not working I
I have set default property page so in the property url it shows /lima-investments/property-name.
i have set a notification when user enters in specific location. what happen when
I have set the title for navigation item on top of the screen. But
I have set a cookie (in Javascript) at: www.sampledomain.com but when I go to
I have set up a JTable and have made it to contain 18 columns.
We have set the following app settings to be iPhone only, but in the

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.