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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:51:23+00:00 2026-06-11T13:51:23+00:00

In application I have a reference table called Cycles that is mapped to Cycle

  • 0

In application I have a reference table called Cycles that is mapped to Cycle entity. Basically most of mapped with NHibernate entities keep references to that table. Usually these entities have fields like:

  • StartCycle
  • ModificationCycle
  • EndCycle
  • Cycle

etc.

Even though I use session per request I still see in logs that majority of queries are issued to Cycles table. This is the case when I query not by Cycle ID, but by other properties that belong to Cycle type.

Cycle type is almost immutable, it has Status property, and actually this is the only property that can be changed by Service classes (like CloseCycleService, Open etc…).
Also Cycle cannot be deleted, but can be inserted.

So I would like to minimize the number of queries to Cycles table.

I could cache it inside ASP .NET by using application cache, and create another layer of abstraction, but before I do it I would like to know that are the options given by NHibernate and what are the drawbacks?

The only problem that I see is multithreading – even though Cycle is almost immutable (and stateless) it could happen that two requests try to modify the same entity at the same time and it could cause an error. But… it is almost impossible.

So could you advice what can I do with NHibernate to store all content of Cycles table in cache (oh, I also didn’t mention that the number of data in that table is small: 1 cycle per month, so currently it’s about 20rows, and will grow 1row per month) and minimize queries that are issued to Cycles table?

  • 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-11T13:51:24+00:00Added an answer on June 11, 2026 at 1:51 pm

    Use the NHibernate second level cache with the SysCacheProvider and query cache – when you create a query for your Cycle entity, call .SetCacheable(true) which will store the results of the query in the cache (as well as the entity itself)

    NHibernate’s second level cache is very well implemented and will keep the cache consistent with any changes you make in the same process. If you are making changes directly in the database, then you can look at the SysCacheProvider2 (I think) which I believe has support for SqlDependencies also.

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

Sidebar

Related Questions

I have a reference application that I use to work through DDD issues, and
I have an ASP.NET (v2.0) web application that uses a reference to a SQL
I have some pages that reference javascript files. The application exists locally in a
I have a entity called Container in a Symfony application, which I have included
Im working on a Web-Application (MyWebApp). I have a Service-Reference to a WCF-Webservice. The
I have a C# application..I continuously get a null reference exception..I manage to catch
I have a .net web application which has a reference to a web service.
I have a VB6 application running for years. This application always reference Excel 2003
I have a Grail application that references a Java library (as an IntelliJ Module
I have an application in mind which dicates database tables be append-only; that is,

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.