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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:45:45+00:00 2026-05-17T06:45:45+00:00

I am getting this exception when I attempt to access an object that is

  • 0

I am getting this exception when I attempt to access an object that is stored in a property of my domain object. I have done some research and still do not understand why I am getting this error.

I have a very basic repository in which I am creating a session and then using a ICriteria query to fetch the first record from the list of results. My Connection domain object has one to many relationship mapped to Server. Why does the session not include the server as a proxy when it fetches the Connection object? I’m not very familiar session managment with NHibernate.

Here is my implementation:

Domain obj:

public class Connection {

public virtual int Id { get; private set; }


public virtual string FullName { get; set; }


public virtual string Email { get; set; }


public virtual string NickName { get; set; }


public virtual string Alternative { get; set; }


public virtual bool IsInvisible { get; set; }


public virtual Server CurrentServer { get; set; }

}

  public Connection GetConnection()
    {
        using (ISession session = NHibernateHelper.OpenSession())
        {
            ICriteria crit = session.CreateCriteria(typeof(Connection));
            crit.SetMaxResults(1);
            IList<Connection> connection = crit.List<Connection>();
            return connection[0];

        }
    }

The above will successfully return a Connection object. However accessing the CurrentServer property with throw the exception. It is/was my assumption that NHibernate was aware of the relationship that this object has with ‘CurrentServer’ and would therefore load that object, lazily, when requested. Can someone tell me where I was led astray?

Thanks!

  • 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-17T06:45:45+00:00Added an answer on May 17, 2026 at 6:45 am

    If it’s a web app., use the session-per-request pattern. If it’s a Windows app. it will take more work. I hold a session open for the lifetime of a Windows Form and dispose it in the FormClosing event. This works great for all but a few cases.

    What won’t I do for 15 points? 🙂

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

Sidebar

Related Questions

I'm getting this exception in an attempt to persist an entity object in an
I am getting an exception thrown when i attempt to access my service, i
I am getting this exception when trying to run my PHP unit tests: Fatal
I am getting this exception: Collection was modified; enumeration operation may not execute. Directly
Hello everyone I am getting this exception: The magic number in GZip header is
I am getting this exception while running any JSP on my tomcat5.5 server.Do I
I am getting this exception while accessing the jax-ws web service from my client.
Hey guys I am getting this exception when trying to run the query Column
I am getting this Exception application openwnn (process jp.co.omronsoft.openwnn) has stopped in the emulator
I am getting this exception in the LogCat: Unable to start service Intent {

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.