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

  • Home
  • SEARCH
  • 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 1096507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:17:39+00:00 2026-05-17T00:17:39+00:00

I have noticed, by using log4net, that when calling ISession.Update, it updates all the

  • 0

I have noticed, by using log4net, that when calling ISession.Update, it updates all the changed objects.

For example:


// Change 2 instances 
user1.IsDeleted = true;
user2.UserName = "Xyz";
// Call session.Update to update the 2 users
using (ITransaction transaction = session.BeginTransaction())
{
    Session.Update(user1); // This updates both user1 & user2
    transaction.Commit();
}
using (ITransaction transaction = session.BeginTransaction())
{
    Session.Update(user2); // Now there is no need for this
    transaction.Commit();
}

Is this the default behavior of NHibernate or has something to do with my mapping file?

Can I make NHibernate update one by one?

  • 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-17T00:17:39+00:00Added an answer on May 17, 2026 at 12:17 am

    It’s the normal and default behavior:

    Hibernate maintains a cache of Objects
    that have been inserted, updated or
    deleted. It also maintains a cache of
    Objects that have been queried from
    the database. These Objects are
    referred to as persistent Objects as
    long as the EntityManager that was
    used to fetch them is still active.
    What this means is that any changes to
    these Objects within the bounds of a
    transaction are automatically
    persisted when the transaction is
    committed. These updates are implicit
    within the boundary of the transaction
    and you don’t have to explicitly call
    any method to persist the values.

    From Hibernate Pitfalls part 2:

    Q) Do I still have to do Save and
    Update inside transactions?

    Save() is only needed for objects that
    are not persistent (such as new
    objects). You can use Update to bring
    an object that has been evicted back
    into a session.

    From NHibernate’s automatic (dirty checking) update behaviour:

    I’ve just discovered that if I get an
    object from an NHibernate session and
    change a property on object,
    NHibernate will automatically update
    the object on commit without me
    calling Session.Update(myObj)!

    Answer: You can set Session.FlushMode to
    FlushMode.Never. This will make your
    operations explicit ie: on tx.Commit() or session.Flush().
    Of course this will still update the
    database upon commit/flush. If you do
    not want this behavior, then call
    session.Evict(yourObj) and it will
    then become transient and NHibernate
    will not issue any db commands for it.

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

Sidebar

Related Questions

I just started using Qt and noticed that all the example class definitions have
I have noticed that when using actionBar.setSelectedNavigationItem(x) in the onCreate() method of my Activity,
Using Dalvic Debug Monitor I have noticed that slight pauses in my game coincide
We're using the LightweightBrowserCache provided by RESTEasy 2.2.3.GA but have noticed that when the
I'm using the i18n feature of Django. I have noticed that even though I
I noticed that the launching of Java applets using deployJava.js seems to have stopped
I'm using protobuf-net r278 in C#, and I just noticed that if I have
I have noticed that when using a SUBMIT type its name attribute gets passed
I'm new to Umbraco. I am using Umbraco 5 RC2. I have noticed that
I have been using php from some time and I have noticed that it

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.