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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:13:32+00:00 2026-06-04T13:13:32+00:00

I am writing a desktop application using NHibernate to connect to the database. My

  • 0

I am writing a desktop application using NHibernate to connect to the database.

My Models have a session that is opened when the model is initialized, and closed when the model is disposed. This is ok when I have one model per form, as the number of open sessions is the same as the number of open windows – a small number.

I am now making a form that lists many models, so if the form lists 50 models, there will be 50 open sessions. I suspect that this may be a problem.

How many open sessions can I have in NHibernate? Should I have only a small number, or can I have as many open sessions as I need?

  • 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-06-04T13:13:33+00:00Added an answer on June 4, 2026 at 1:13 pm

    It depends how long you keep your sessions open for and what you do with them. The session itself is pretty lightweight and doesn’t necessarily open a connection to the database.

    However I think that having 50 open sessions for 1 form is not the best design. I would suggest using a session as a “unit of work” in that when you want to do something (such as present some data, or update some data, or list a bunch of entities), you open the session, do your work, and then dispose of the session. This can cause some issues with lazy loading and data-binding, but you can work around those by fetching the required associations.

    You can reconnect entities that you have loaded in one session into another by using session.Lock(entity, LockMode.None), so you don’t need to have the session open between user interactions.

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

Sidebar

Related Questions

I'm writing a WPF desktop application and have a view that needs to look
I am writing a desktop application using vb.net. In that application one screen needs
I am writing a desktop application using MVVM and Prism and I have the
I'm writing a facebook desktop application for the first time using the PyFacebook api.
I am writing a desktop and j2me application. I have debug statements in program.
We're writing Windows desktop apps using C++ and Win32. Our dialog boxes have an
I am writing a Desktop GUI application in Clojure using Java Swing. Normally when
I've been writing a small desktop gadget-type application that displays scrolling text along the
I am writing a Desktop application for professional users using C++. My current design
I'm writing a Java SE (desktop) application that has to access different databases all

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.