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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:13:33+00:00 2026-05-13T22:13:33+00:00

A project I am working on uses Spring 2.5 & JPA with Hibernate as

  • 0

A project I am working on uses Spring 2.5 & JPA with Hibernate as a provider.

My DAO classes extend JpaDaoSupport, so I get my JpaTemplate using the getJpaTemplate() method.

The back-end database can get changed either by my application, or a third-party application.

When a third-party application changes the database (mostly configuration data changes), I need to provide the user of my application a way to invalidate all JPA sessions and reload the new data (i.e. invalidate all the hibernate sessions in the background). This needs to be “seen” by all concurrent users of my application.

How can I do this?

  • 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-13T22:13:34+00:00Added an answer on May 13, 2026 at 10:13 pm

    There are two levels of caches:

    • 1st level is the EntityManager’s own cache.

    You can either refresh on one entity and it will be reloaded form the database, or you can clear the entity manager itself, in which case all entities are removed from the cache. There is no way with JPA to evict only one specific entity from the cache. Depending on the implementation you use, you can do this, e.g. Hibernate’s evict method.

    • 2nd level caching is the global cache.

    JPA 1.0 did not provide support for 2nd level cache. You need then to rely on the underlying specific implementation, or to disable it. JPA 2.0 will address this issue with @Cache annotation and the cache API. You can clear the 2nd level cache using Hibernate-specific API, e.g. SessionFactory.evict(...).

    • Unerstanding Hibernate 2nd level cache

    Advanced issues with caching are:

    • Query cache

      Result of certain queries can be cached. Again not support for it in JPA 1.0, but most implementation have ways to specify which query will be cached and how.

      • Understanding the query cache in Hibernate
    • Clustering

      Then comes also the tedious problem of synchronizing caches between nodes in a cluster. In this case, this mostly depend on the caching technology used, e.g. JBoss cache.

    Your question is still somehow generic and the answer will depend on what you are exactly doing.

    I worked on a system were many updates would be done without going through hibernate, and we finally disabled the 2nd level cache.

    But you could also keep track of all opened sessions, and when necessary evict all 1st level cache of all opened session, plus the 2nd level cache. You would still need to manage synchronization yourself, but I imagine it’s possible.

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

Sidebar

Related Questions

I am working on a project that uses hibernate and spring. Hibernate is encapsulated
I am working on a Silverlight project that uses Django on the server using
The Situation I'm working on a group web project which uses the Spring framework.
I'm working on a project which currently uses NHibernate 2.1.2, FluentNHibernate 1.1 and Spring.Net
I'm currently working on a Java EE project which uses JPA. I'm connecting to
I am working on a project using Java and Spring 3. There is a
I have been working on a project which uses Grails with Hibernate... Now the
I'm working on a project which uses user authentication. I'm facing a issue with
I'm working on an embedded project that currently uses C in Linux and uClibc.
I'm working on a project that uses several languages: SQL for querying a database

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.