Multiple choice technology programming languages

It is possible to re-load an object and all its collections at any time, using the xxxx() method. This is useful when database triggers are used to initialize some of the properties of the object.What is the xxxx() method ?

  1. refresh();

  2. flush();

  3. fetch();

  4. load()

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The refresh() method re-loads the object and all its collections from the database, overwriting any changes made to the persistent object. This is particularly useful when database triggers modify properties after the initial load. Unlike flush() which writes changes to the database, refresh() synchronizes the in-memory object with the database state.

AI explanation

Hibernate's Session.refresh() method re-reads an object's state (and its associated collections) directly from the database, discarding any in-memory changes, which is useful when database-side logic like triggers may have modified column values that the in-memory object doesn't yet reflect.