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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:37:12+00:00 2026-05-27T00:37:12+00:00

I have a problem with this piece of code If I don’t use the

  • 0

I have a problem with this piece of code
If I don’t use the transaction (I commented here in that code), the update won’t occur.

using (var session = Repository.TSession())
{
  var utilisateurDal = new UtilisateurDal(session);
  var utilisateur = utilisateurDal.GetUtilisateur(login);
  if (utilisateur != null)
  {
    //var transaction = Session.BeginTransaction();
    utilisateur.MotDePasse = "test";
    session.Update(utilisateur);
    //transaction.Commit();
  }
}

The code which retrieve the object to update :
(Please note that login isn’t an unique identifier)

public Utilisateur GetUtilisateur(ISession session, string login)
{
  return session.Query<Utilisateur>().SingleOrDefault(u => u.Identifiant == login);
}

When I enable the debug mode I have that message :

NHibernate.Event.Default.DefaultSaveOrUpdateEventListener: 2011-11-16 14:14:57,832 [35] DEBUG NHibernate.Event.Default.DefaultSaveOrUpdateEventListener [(null)] - ignoring persistent instance
NHibernate.Event.Default.DefaultSaveOrUpdateEventListener: 2011-11-16 14:14:57,833 [35]     DEBUG NHibernate.Event.Default.DefaultSaveOrUpdateEventListener [(null)] - object already associated with session: [BusinessObjets.Utilisateur#3]

Do you the meaning of this behaviour ?

Regards

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

    NHibernate doesnt send the Update-statement immediatly and will cache it. On the next session.Flush() all Updates are sent together to save roundtrips. transaction.Commit() will Flush all changes to the db, otherwise a commit in the db wont know the updates.

    you can even omit session.Update(utilisateur); because the session tracks the entities loaded through it and will send all changes to db on the next Flush().

    Either use a transaction or call session.Flush(); at the end of your updates.

    this could look like this

    using (var session = Repository.TSession())
    using (var transaction = Session.BeginTransaction())
    {
        var utilisateurDal = new UtilisateurDal(session);
        var utilisateur = utilisateurDal.GetUtilisateur(login);
        if (utilisateur != null)
        {
            utilisateur.MotDePasse = "test";
        }
        transaction.Commit();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've wrote this simple piece of code. And I have a slight problem with
I have a piece of code that I don't know how to improve it.
I have a ugly piece of code that adds event handlers. The problem is,
I have a big problem writing a small piece of code using JS/jQuery (don't
I have problem compilin this code..can anyone tell whats wrong with the syntax CREATE
I have problem with this code: file = tempfile.TemporaryFile(mode='wrb') file.write(base64.b64decode(data)) file.flush() os.fsync(file) # file.seek(0)
Hi i have problem with this code, i found it on the internet and
i am a beginner and i have a problem : this code doesnt compile
I need help with debugging this piece of code. I know the problem is
I have a piece of code that needs to be able to modify a

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.