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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:19:08+00:00 2026-05-22T17:19:08+00:00

I have a Hibernate Entity in my code. i would fetch that and based

  • 0

I have a Hibernate Entity in my code. i would fetch that and based on the value of one of the properties ,say “isProcessed” , go on and :

  1. change value of “isProcessed” to “Yes” (the property that i checked)
  2. add some task to a DelayedExecutor.

in my performance test, i have found that if i hammer the function,a classic dirty read scenario happens and i add too many tasks to the Executor that all of them would be executed. i can’t use checking the equality of the objects in the Queue based on anything , i mean java would just execute all of them which are added.

how can i use hibernate’s dirty object stuff to be able to check “isProcessed” before adding the task to executor? would it work?

hope that i have been expressive enough.

  • 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-22T17:19:09+00:00Added an answer on May 22, 2026 at 5:19 pm

    If you can do all of your queries to dispatch your tasks using the same Session, you can probably patch something together. The caveat is that you have to understand how hibernate’s caching mechanisms (yes, that’s plural) work. The first-level cache that is associated with the Session is going to be the key here. Also, it’s important to know that executing a query and hydrating objects will not look into and return objects from the first-level cache…the right hand is not talking to the left hand.

    So, to accomplish what you’re trying to do (assuming you can keep using the same Session…if you can’t do this, then I think you’re out of luck) you can do the following:

    1. execute your query
    2. for each returned object, re-load it with Session’s get method
    3. check the isProcessed flag and dispatch if need-be

    By calling get, you’ll be sure to get the object from the first-level cache…where all the dirty objects pending flush are held.

    For background, this is an extremely well-written and helpful document about hibernate caching.

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

Sidebar

Related Questions

Let's say I have this entity (for Hibernate): @Entity public class Person { @Id
We have a DB table that is mapped into a hibernate entity. So far
I have a question about how Hibernate persists entity relations. Let's say I have
We have a project that uses JPA/Hibernate on the server side, the mapped entity
Imagine that you have a Person entity with a one to one relationship with
I have a service that gets a JPA entity from outside code. In this
I have an entity loaded by Hibernate (via EntityManager ): User u = em.load(User.class,
I have a problem with a query using hibernate. The entity class EntityClass has
You can also write hibernate hql or criteria queries. I have Teacher entity and
We have hibernate-based system and customer wants to get human-readable names of PK and

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.