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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:16:22+00:00 2026-05-23T03:16:22+00:00

I have a long-running EntityManager which I periodically clear(). I have a read-write cache

  • 0

I have a long-running EntityManager which I periodically clear(). I have a read-write cache configured on one of my entities.

I have done some investigation and I can see that the entity is present in the cache. I can even see a cache hit from net.sf.ehcache.Cache.searchInStoreWithStats(). However, ehcache will not return the entity if its timestamp is later than the timestamp when the session was created: see AbstractReadWriteEhcacheAccessStrategy.get(Object, long).

What is the reason for this behaviour? Is there a way I can customise hibernate or ehcache to achieve cache hits within a single EntityManager?

  • 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-23T03:16:23+00:00Added an answer on May 23, 2026 at 3:16 am

    It looks like this is a property of a read-write cache: you can’t fetch an entity from the cache that was created in the same session.

    A non-strict read-write cache doesn’t compare timestamps, so this does achieve a cache hit after the first load().

    Even better, a transactional cache populates the cache after persist(), so the very first load() will result in a cache hit. Since my interaction with the databse is entirely within a single thread in a single JVM, I believe this is safe to use.

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

Sidebar

Related Questions

i have a long running function¹: public string FindPasswordFromHash(String hash) { ... } which
I have a long running PHP script that has a memory leak which causes
I have a long running program that exectues some mySQL-Queries every 5 minutes (timed
I have some long-running Java code running in a thread started by a Java
I have a long running program, my_prog that has some output that I want
I currently have a long running thread which uses a hibernate session to perform
I have a long running task and a Dialog which informs the User that
I have some long-running CLI PHP scripts that run regularly via cron. I'd like
I have a long running SQL statement that I want to run, and no
I have a long running process in VB6 that I want to finish before

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.