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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:02:38+00:00 2026-05-14T01:02:38+00:00

I have what may be a pretty elementary Hibernate question. Do HQL (and/or Criteria)

  • 0

I have what may be a pretty elementary Hibernate question. Do HQL (and/or Criteria) update queries cause updates to live domain objects? And do they automatically flush now-invalid domain objects from the first-level cache?

Example:

Player playerReference1 = session.get(Player.class,1);
session.createQuery("update players set gold = 100").executeUpdate();
//Question #1 -- does playerReference1.getGold() now return 100?
Player playerReference2 = session.get(Player.class,1);
//Question #2 -- does playerReference2.getGold() return 100, or is it the same exact object?

Should I make a practice of evicting all objects that are affected by an HQL update if there’s a chance some code will need it later?

  • 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-14T01:02:39+00:00Added an answer on May 14, 2026 at 1:02 am

    The answer to both questions is no. According to Java Persistence with Hibernate, chapter 12:

    If you execute an SQL statement that operates directly on the rows in the database, any change you make doesn’t affect the in-memory objects (in whatever state they may be). In other words, any direct DML statement bypasses the Hibernate persistence context (and all caches).

    This applies to HQL as well. They recommend executing DML before loading any objects from the session.

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

Sidebar

Related Questions

I have a question which may be somewhat silly because I'm pretty sure I
I have a list of user identifiers which are pretty long. The identifiers may
As you may have guessed from the question - I am right at the
This question may have been asked before, but I had trouble finding an answer,
(I'm pretty new to WPF, so this question may seem obvious or inconsistent.) There
--EDIT-- I believe this is a valid question that may have multiple answers (as
I asked a similar question yesterday which may have been poorly worded, either way
This question may be pretty simple, but i dont find exact answers .. in
You may have heard of PawSense , a Windows-only utility that prevents keystrokes from
This may have been answered before, and if so, point me to the answer.

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.