If I save an entity using a Hibernate session, and then probe to get this entity from the current session on the very next line (i.e. without the changes have been written to DB yet) will the session return an object? I assume it should, because it is also aware of what changes have been made to it.
Share
Yes, the view of entities that have been saved and those being loaded/queries should be consistent. Sometimes querying causes all the outstanding changes to the database to be flushed before the query is performed, in order to produce this consistency (assuming the session is set to the default auto-flush mode).
Further, in this case, the session should return the exact same object that you saved, not a copy that refers to the same row in the database.