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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:30:52+00:00 2026-06-10T03:30:52+00:00

After my queries(lookups) get cached session closes, in a new session, hibernate is evicting

  • 0

After my queries(lookups) get cached session closes, in a new session, hibernate is evicting everything after I change the DB through a random write Sql Query, how can I stop that from happening ? I’m looking into creating policies for things that rarely change.

INFO    Executing [namedSqlQuery=dao.web_login, objs=[user1]] 
DEBUG   org.springframework.orm.hibernate3.SessionFactoryUtils user1- Opening Hibernate Session 
DEBUG   org.hibernate.impl.SessionImpl user1 - opened session at timestamp: 5511432318976000 
DEBUG   org.hibernate.impl.SessionFactoryImpl user1- evicting second-level cache: USERS_LOOKUP 
DEBUG   org.hibernate.impl.SessionFactoryImpl user1- evicting second-level cache: COUNTRY_LOOKUP

ecache.xml

 <cache name="query.oneHourPolicy"
           maxElementsInMemory="10000"
           eternal="false"
           timeToLiveSeconds="3600"
           diskPersistent="true"
           overflowToDisk="true"/>

spring hibernate configuration

 <prop key="hibernate.cache.use_second_level_cache">true</prop>
                <prop key="hibernate.cache.use_query_cache">true</prop>
                <prop key="hibernate.cache.provider_class">net.sf.ehcache.hibernate.SingletonEhCacheProvider</prop>
                <prop key="hibernate.cache.provider_configuration_file_resource_path">ehcache.xml</prop>
  • 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-10T03:30:54+00:00Added an answer on June 10, 2026 at 3:30 am

    found the Hibernate Issue https://hibernate.onjira.com/browse/HHH-2224

    I tested with the bellow :

    in my random query

    <sql-query name="random_write_query" callable="false">
            <synchronize table="USER"/>
            <synchronize table="USER_ADDRESS"/>
            {CALL PACKAGE.FUNCTION(?)}
    </sql-query>
    

    whenever I call the above and it’s a DB change it will invalidate only the cache syncronized by table = USER or USER_ADDRESS

    and only syncronized random read queries or entities will be evicted

    <sql-query name="random_read_query">
             <synchronize table="USER"/>
             <synchronize table="USER_ADDRESS"/>
             <return-scalar column="USERNAME" type="string"/>
            <![CDATA[
                SELECT USERNAME FROM USER, USER_ADDRESS...
            ]]>
        </sql-query>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm sending some queries using Java client API. but I get following error after
Sometimes I have to run multiple queries (one after another) with slightly different arguments
I've noticed that my code errors out on sqlWrite.ExecuteNonQuery(); after executing 200 Insert queries
After some time researching and trying different things I still cannot get my @ExceptionHandler
I noticed some queries were running quite slow all of the sudden. After running
I need some alternative of implode for mysql queries.After research found concat functions. Question
Surprisingly, after having done a lot of queries without problem. I've run into the
Been writing some raw SQL queries after noticing how inefficient some of Django's built-in
Major Update after a couple days of debugging: I run a few queries similar
I wrote some queries in C# using LINQ. After a while, I started using

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.