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

  • Home
  • SEARCH
  • 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 8150969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:13:19+00:00 2026-06-06T15:13:19+00:00

I’ve got a probably embarrassingly easy question regarding Hibernate: When I’ve got a persisted

  • 0

I’ve got a probably embarrassingly easy question regarding Hibernate:

When I’ve got a persisted instance of an object, and some of these object’s properties are modified inside the same Session, are those changes visible for me too?

Or do I have to refresh the object in order to get it’s current state?


I’d like to extend my question: What if these changes are not made inside the same Session? What if they are made in a Session, provided by the same SessionFactory?

  • 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-06-06T15:13:20+00:00Added an answer on June 6, 2026 at 3:13 pm

    If you have an entity loaded two or more times (doesn’t matter if with Query.list() or Session.load()) then always you get the same instance of the Java object. And as it is the same instance, each modification of this instance is visible wherever you use this instance, and so this also is the case for modifications which are not persisted to the database (which is a certain danger).

    If the entity is loaded two times using two different sessions (it doesn’t matter if the sessions are from the same SessionFactory or not), then you get two instances of the Java class. These two instances are independent. One instance does not get informed about modifications in the other instance. This also is not the case if the modification is persisted into the database. Even if you load again the entity and it is already in the session cache, you do not get the modification (Example: session1.load(entity); session2.save(entity); session1.load(entity); then session1 does not load the changes which session2did, because the entity already was in the cache). The same is the case if a modification is done directly with SQL outside your program. To load the modification you either have to evict() the instance or use a new session. In this case it is recommendable to have a versioned column (a column mapped with the <version> clause) to avoid losses of modifications.

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

Sidebar

Related Questions

i got an object with contents of html markup in it, for example: string
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
this is what i have right now Drawing an RSS feed into the php,
Specifically, suppose I start with the string string =hello \'i am \' me And
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.