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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:18:37+00:00 2026-05-15T21:18:37+00:00

The entities and mappings I’m talking about in this question can be found here

  • 0

The entities and mappings I’m talking about in this question can be found here 🙂

Here is the context:

I have a parent view-model which helps to manage some entities, and which has its own session.

From this VM, I open another view-model (with its own session too), do some changements to the entity (add and/or remove children), and when I validate the changements, I commit the session and warns the first view-model to refresh the display:

public void Validate()
{
    using (var tx = Session.BeginTransaction())
    {
        try
        {
            SelectedTeam.ClearRoster();

            foreach (var teamPlayer in TeamPlayers)
                SelectedTeam.AddPlayer(teamPlayer);

            teamsRepository.SaveOrUpdate(SelectedTeam);

            tx.Commit();
        }
        catch (Exception ex)
        {
            tx.Rollback();
        } 
        finally
        {
            if (tx.WasCommitted)
                ServiceLocator.Current.GetInstance<Mediator>().NotifyColleagues(MediatorMessages.DisplayEntityInfos, SelectedTeam.Id);
        }
    }
}

Here is the faulted method of the parent VM:

public void RefreshEntitiesListAndDisplayEntityInfos(int selectedEntityId)
{
    TEntity entity = entitiesRepository.Load(selectedEntityId);
    Session.Refresh(entity);
    //...
}

The exception is thrown at the Refresh line:

NHibernate.UnresolvableObjectException

And the message is:

No row with the given identifier exists[Emidee.CommonEntities.PlayerInTeam#3

I can open and change the entity multiple times, but it seems that the exception is thrown when I delete a children, then add another one, and finally delete another one.

After some readings on the web, it seems that’s because when I refresh the entity, and because I changed the HasMany relationship (because I have deleted a player for example), NH tries to reload the deleted row.

I’ve tried to add a NotFound.Ignore statement on the HasMany in my mappings, I’ve tried to force a new query to the DB instead of a Load, but I still get this exception.

Does someone know how I could fix that?

Thanks in advance

Mike

  • 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-15T21:18:38+00:00Added an answer on May 15, 2026 at 9:18 pm

    This is a known behavior when refreshing objects with modified collections.

    To force reload, change your method to do session.Evict with the entity as a parameter. This is the code we use in our base model class:

    public T ReGet<T>(T entity) where T : IEntity
    {
        var id = entity.Id;
        Session.Evict(entity);
        return Session.Get<T>(id);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.