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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:24:22+00:00 2026-06-11T05:24:22+00:00

I was doing a simple 2 level caching experiment with Stored Procedures and am

  • 0

I was doing a simple 2 level caching experiment with Stored Procedures and am receiving a table or view does not exist Oracle error.

The cache is retrieving my DTO object and trying to make a SQL statement to the database. I’m guessing it is some configuration error.

Here’s the app.config

<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory name="NHibernate.Test">
  <property name="connection.driver_class">NHibernate.Driver.OracleDataClientDriver</property>
  <property name="show_sql">true</property>
  <property name="dialect">NHibernate.Dialect.Oracle10gDialect</property>
  <property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
  <property name="cache.use_query_cache">true</property>
  <property name="cache.use_second_level_cache">true</property>
  <property name="cache.provider_class">NHibernate.Caches.SysCache.SysCacheProvider, NHibernate.Caches.SysCache</property>
</session-factory>
</hibernate-configuration>

And here’s the code to test:
[TestMethod]
public void GetNomHeaderInfo_TestingCache_BPNomHeaderShouldBeCached()
{
//Arrange
DateTime StartTime;
DateTime EndTime;
TimeSpan FirstTry;
TimeSpan SecondTry;

    //Act
    using (var session = factory.OpenSession())
    {
        var query = session.GetNamedQuery("GetMyDTO");
        query.SetInt32("id", 1);
        query.SetCacheRegion("Id");
        query.SetCacheMode(CacheMode.Normal);
        query.SetCacheable(true);
        StartTime = DateTime.Now;
        myDTO DTO = query.UniqueResult<myDTO>();
        EndTime = DateTime.Now;
        FirstTry = EndTime - StartTime;
    }

    using (var session = factory.OpenSession())
    {
        var query = session.GetNamedQuery("GetMyDTO");
        query.SetInt32("id", 1);
        query.SetCacheRegion("Id");
        query.SetCacheMode(CacheMode.Normal);
        query.SetCacheable(true);
        StartTime = DateTime.Now;
        myDTO DTO = query.UniqueResult<myDTO>();
        EndTime = DateTime.Now;
        SecondTry = EndTime - StartTime;
    }

    //Test
    Assert.IsTrue(SecondTry < FirstTry);
}

I then error out when I do the second query.UniqueResult(); The error message is:

SELECT blah blah_.blahblah, etc FROM MyDTO SomeAlias_ WHERE SomeAlias_.id=:p0

But there’s no myDTO table or view. I don’t know why NHibernate thinks to pull from the cache myDTO and then tries to create a SQL statement.

Here’s the trace:

NHibernate.Cache.StandardQueryCache: DEBUG checking cached query results in region: 'Id'; sql: { call SomePackage.MyProc(?) }; parameters: []; named parameters: {'id'='1'}
NHibernate.Cache.StandardQueryCache: DEBUG checking cached query results in region: 'Id'; sql: { call SomePackage.MyProc(?) }; parameters: []; named parameters: {'id'='1'}
NHibernate.Caches.SysCache.SysCache: DEBUG Fetching object 'NHibernate-Cache:nomId:sql: { call SomePackage.MyProc(?) }; parameters: []; named parameters: {'id'='1'}@601355831' from the cache.
NHibernate.Caches.SysCache.SysCache: DEBUG Fetching object 'NHibernate-Cache:nomId:sql: { call SomePackage.MyProc(?) }; parameters: []; named parameters: {'id'='1'}@601355831' from the cache.
NHibernate.Cache.StandardQueryCache: DEBUG Checking query spaces for up-to-dateness [MyDTO]
NHibernate.Cache.StandardQueryCache: DEBUG Checking query spaces for up-to-dateness [MyDTO]
NHibernate.Caches.SysCache.SysCache: DEBUG Fetching object 'NHibernate-Cache:UpdateTimestampsCache:MyDTO@1270222867' from the cache.
NHibernate.Caches.SysCache.SysCache: DEBUG Fetching object 'NHibernate-Cache:UpdateTimestampsCache:MyDTO@1270222867' from the cache.
NHibernate.Cache.StandardQueryCache: DEBUG returning cached query results for: sql: { call SomePackage.MyProc(?) }; parameters: []; named parameters: {'id'='1'}
NHibernate.Cache.StandardQueryCache: DEBUG returning cached query results for: sql: { call SomePackage.MyProc(?) }; parameters: []; named parameters: {'id'='1'}
NHibernate.Event.Default.DefaultLoadEventListener: DEBUG loading entity: [MyAssembly.MyDTO#1]
NHibernate.Event.Default.DefaultLoadEventListener: DEBUG loading entity: [MyAssembly.MyDTO#1]
NHibernate.Event.Default.DefaultLoadEventListener: DEBUG attempting to resolve: [MyAssembly.MyDTO#1]
NHibernate.Event.Default.DefaultLoadEventListener: DEBUG attempting to resolve: [MyAssembly.MyDTO#1]
NHibernate.Event.Default.DefaultLoadEventListener: DEBUG object not resolved in any cache: [MyAssembly.MyDTO#1]
NHibernate.Event.Default.DefaultLoadEventListener: DEBUG object not resolved in any cache: [MyAssembly.MyDTO#1]
NHibernate.Persister.Entity.AbstractEntityPersister: DEBUG Fetching entity: [MyAssembly.MyDTO#1]
NHibernate.Persister.Entity.AbstractEntityPersister: DEBUG Fetching entity: [MyAssembly.MyDTO#1]
NHibernate.Loader.Loader: DEBUG loading entity: [MyAssembly.MyDTO#1]
NHibernate.Loader.Loader: DEBUG loading entity: [MyAssembly.MyDTO#1]
NHibernate.AdoNet.AbstractBatcher: DEBUG Opened new IDbCommand, open IDbCommands: 1
NHibernate.AdoNet.AbstractBatcher: DEBUG Opened new IDbCommand, open IDbCommands: 1
NHibernate.AdoNet.AbstractBatcher: DEBUG Building an IDbCommand object for the SqlString: SELECT blah blah_.blahblah, etc FROM MyDTO SomeAlias_ WHERE SomeAlias_.id=:p0

Anyone know what I’m doing wrong here?

Thanks, Bill N

  • 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-11T05:24:24+00:00Added an answer on June 11, 2026 at 5:24 am

    I can’t see your mapping, but here’s an explanation.

    • You are caching your query results, but not your entity (those are separate caches)
    • Caching a query’s results just stores the IDs; if you are not caching your entities too, a query is issued to load each returned entity (this is usually bad)
    • The default table name for the MyDTO class is MyDTO, so that’s where it’s looking
    • This looks like a Query by ID, for which you shouldn’t be using a loose named query, but a proper loader (see 17.4. Custom SQL for loading).

    Once you set up the loader and entity caching, you’ll just be able to retrieve your objects using just session.Get<MyDTO>(id), which will use the second level cache, as long as you do all of your work inside transactions, which is a recommended practice.

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

Sidebar

Related Questions

In My iphone Application,I am doing simple image animation in a View and in
I've been doing simple multi-threading in VB.NET for a while, and have just gotten
I'm doing simple divisions in c#, and I am a bit puzzled by its
What's the easiest way of doing simple pattern matching a la .something.com something.com/ something.com/somefolder/*.jpg
I'm considering the feasibility of doing simple reporting on Trello data. My quick review
I have a WCF service hosted in IIS6. It is doing simple WebRequest. When
on my master page, I have referenced jquery file. I am doing simple hover
Doing a simple Squeryl database lookup, but trying to exclude a value. I've tried:
Im doing a simple ajax request like:` $.ajax({ type: 'POST', url: 'http://' + serverIP
I am doing a simple JSP program to connect with MySQL DB. But it's

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.