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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:05:30+00:00 2026-05-28T14:05:30+00:00

This Hibernate configuration ostensibly should control how many objects are cached in the first

  • 0

This Hibernate configuration ostensibly should control how many objects are cached in the first level cache. The reason is easy enough to understand, we don’t want to run out of memory.

But something is confusing me. Every implementation I have seen including this website
has an explicit flush and clear. No problem, but then what’s point of the configuration property?

Note: I’m assuming here is that somehow Hibernate monitors the size of the cache and if the number of objects of a certain type grows to be larger than the cache size then synchronize the cache with the db. Don’t know if that assumption is wrong ???

  • 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-28T14:05:31+00:00Added an answer on May 28, 2026 at 2:05 pm

    This configuration option has nothing to do with the size of the first-level cache. And flushing the session doesn’t remove anything from the cache. It writes the pending changes (inserts, deletes, updates) to the database. The cache is only cleared when clear() is explicitely called, or when the session is closed. If you don’t clear or clause the session (or evist specific entities), the cache will keep growing and growing. Which is not a problem since it’s typically very short-lived (the duration of a transaction).

    JDBC batch updates allow sending multiple update queries in a single batch to the database. It reduces the number of network calls. You can view it as uploading an uncompressed zip containing 20 files instead of sending 20 files individually.

    The confusion comes from the fact that the batch updates mentioned in the page linked in your question have nothing to do with JDBC batch updates. What Hibernate means with batch updates is “updates done by a batch job”. A batch job typically have much longer transactions that typical business use-cases, and updates hundreds, thousands or even more entities in a single transaction. This is why Hibernate recommends regularly flushing and clearing the session in this case, to avoid running out of memory.

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

Sidebar

Related Questions

In many past projects, I used this JPA / Hibernate approach to add auditing
I need this roadmap of a Hibernate managed object instance. First, I create an
I tried to use a cache configuration like this post from a website: <configSections>
I am trying to obtain Spring-defined Hibernate Configuration and SessionFactory objects in my non-Spring
I've this configuration in the hibernate.cfg.xml: <?xml version=1.0 encoding=utf-8 ?> <hibernate-configuration xmlns=urn:nhibernate-configuration-2.2> <session-factory> <property
What is wrong with this configuration? I'm using Spring 3 and Hibernate 3.6 and
This is question about java hibernate. my hibernate.cfg.xml is <?xml version=1.0 encoding=UTF-8?> <!DOCTYPE hibernate-configuration
Ok, I have this spring hibernate xml configuration. <bean id=sessionFactory class=org.springframework.orm.hibernate3.LocalSessionFactoryBean> <property name=dataSource ref=dataSource
I have this code: SessionFactory sessionFactory = new Configuration().configure(hibernate.cfg.xml); How i may to configure
My configuration looks like this: <hibernate-configuration xmlns=urn:nhibernate-configuration-2.2 > <session-factory name=kvws.kist.suche.dbadapter.nhentities> <!-- Driver --> <property

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.