Multiple choice technology programming languages

If you are not certain that a matching row exists in the database then which method is the best ?

  1. Session.load();

  2. Session.get();

  3. Session.fetch();

  4. None of the above

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

In Hibernate, Session.get() immediately queries the database and returns null if the corresponding row does not exist, which is ideal when existence is uncertain. Conversely, Session.load() assumes the row exists, returns a proxy, and throws an exception later if the record is missing.