Which of the following is FALSE about Session in hibernate

  1. Session is a light weight non-threadsafe object

  2. You can share the session between threads

  3. Session represents a single unit-of-work with the database

  4. Session is the primary interface for the persistence service

  5. A session loads database connections using lazy-loading


Correct Option: B

AI Explanation

To answer this question, we need to understand the concept of a Session in Hibernate.

A Session in Hibernate represents a single unit-of-work with the database. It is the primary interface for the persistence service and is used to perform database operations such as saving, updating, and deleting objects.

Now, let's go through each option to determine which one is FALSE:

Option A) Session is a lightweight non-threadsafe object - This option is TRUE. A Session in Hibernate is a lightweight object that is not thread-safe. It should not be shared between multiple threads.

Option B) You can share the session between threads - This option is FALSE. As mentioned earlier, a Session in Hibernate is not thread-safe and should not be shared between threads.

Option C) Session represents a single unit-of-work with the database - This option is TRUE. A Session represents a single database transaction and is used to perform a specific unit of work with the database.

Option D) Session is the primary interface for the persistence service - This option is TRUE. The Session interface is the primary interface for interacting with the persistence service in Hibernate.

Option E) A session loads database connections using lazy-loading - This option is FALSE. A Session in Hibernate does not directly load database connections. Instead, it loads and manages persistent objects from the database using lazy-loading or eager-loading strategies.

Therefore, the FALSE statement about a Session in Hibernate is option B) You can share the session between threads.

Find more quizzes: