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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:28:44+00:00 2026-05-29T12:28:44+00:00

I’m working with c# and nhibernate to access the database. I have two or

  • 0

I’m working with c# and nhibernate to access the database.
I have two or three terminals who can realize same actions, like edit, or remove entities from the same DB.
My problem is that my terminal does not realize if another terminal made any change on the database, although i refresh the data executing the queries again.
I think it’s due to the cache.
I’ve tryed Flush() and Evict() commands with no results.
I wish somebody could help me, sorry for my terrible english

—–Info Added ——-

It’s a c# desktop application.
I don’t see any errors, the problem is that when i edit or delete i need to know if the entity was modified from another terminal. and when i bring the entity from database, i’m not seeig the changes mades from another terminal until y restart the application.

The session is created by the next code :

[PossibleLongOperation]
        private void DoConnectionWork(string nhibernateConfigPath)
        {
            String appPath = Directory.GetParent(Assembly.GetAssembly(GetType()).Location).FullName;
            String serializablefilePath = Path.Combine(appPath, "configuration.serialized");
            try
            {
                if (IsConfigurationFileValid(serializablefilePath))
                {
                    Configuration = LoadConfigurationFromFile(serializablefilePath);
                }
                else
                {
                    // configuration is immutable, store last returned value
                    Configuration = new Configuration();
                    Configuration.Configure(nhibernateConfigPath);
                    Configuration.AddAssembly(typeof(ObjectEntity).Assembly);
                    SaveConfigurationToFile(serializablefilePath, Configuration);
                    new SchemaUpdate(Configuration).Execute(true, true);
                    Console.WriteLine(@"Se solicitó la actualización de datos");
                }
                //NHibernateSchemaExport();
            }
            catch (Exception ex)
            {
                //if(File.Exists(serializablefilePath))
                //    File.Delete(serializablefilePath);
                throw new GenericRepositoryException(string.Format("Error while configuring NHibernate: {0}.", ex.Message), ex);
            }

            try
            {
                SessionFactory = Configuration.BuildSessionFactory();
            }
            catch (Exception ex)
            {
                //if (File.Exists(serializablefilePath))
                //    File.Delete(serializablefilePath);
                throw new GenericRepositoryException(string.Format("Error while building NH session factory: {0}.", ex.Message), ex);
            }
        }

———-Added————-

this is the exception i get after Clear() the session

09-02-2012 13:22:54|Error|Error:  
NHibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: 394, of entity: Model.Pedido
   en NHibernate.Engine.StatefulPersistenceContext.CheckUniqueness(EntityKey key, Object obj) en d:\CSharp\NH\NH\nhibernate\src\NHibernate\Engine\StatefulPersistenceContext.cs:línea 688
   en NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.PerformUpdate(SaveOrUpdateEvent event, Object entity, IEntityPersister persister) en d:\CSharp\NH\NH\nhibernate\src\NHibernate\Event\Default\DefaultSaveOrUpdateEventListener.cs:línea 227
   en NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.EntityIsDetached(SaveOrUpdateEvent event) en d:\CSharp\NH\NH\nhibernate\src\NHibernate\Event\Default\DefaultSaveOrUpdateEventListener.cs:línea 186
   en NHibernate.Event.Default.DefaultUpdateEventListener.PerformSaveOrUpdate(SaveOrUpdateEvent event) en d:\CSharp\NH\NH\nhibernate\src\NHibernate\Event\Default\DefaultUpdateEventListener.cs:línea 29
   en NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.OnSaveOrUpdate(SaveOrUpdateEvent event) en d:\CSharp\NH\NH\nhibernate\src\NHibernate\Event\Default\DefaultSaveOrUpdateEventListener.cs:línea 53
   en NHibernate.Impl.SessionImpl.FireUpdate(SaveOrUpdateEvent event) en d:\CSharp\NH\NH\nhibernate\src\NHibernate\Impl\SessionImpl.cs:línea 2666
   en NHibernate.Impl.SessionImpl.Update(Object obj) en d:\CSharp\NH\NH\nhibernate\src\NHibernate\Impl\SessionImpl.cs:línea 524
   en Besnik.GenericRepository.NHibernate.NHibernateUnitOfWork.Update[TEntity](TEntity entity)
   en Besnik.GenericRepository.GenericRepository`2.Update(TEntity entity)
   en Services.Services.Implementation.PedidoServiceImpl.<>c__DisplayClass8.<Anular>b__7() en C:\Repositorio\ProyectosCasinoClub\SPMontaPlatosOK\Code\Services\Services\Implementation\PedidoServiceImpl.cs:línea 72
   en Services.Transaction.Transaction.Execute(Action transactionalAction, Action`1 onException) en C:\Repositorio\ProyectosCasinoClub\SPMontaPlatosOK\Code\Services\Transaction\Transaction.cs:línea 32
  • 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-29T12:28:45+00:00Added an answer on May 29, 2026 at 12:28 pm

    Did you try clearing the L1 session cache, by session.Clear() ?

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a jquery bug and I've been looking for hours now, I can't
I have a reasonable size flat file database of text documents mostly saved in
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace

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.