Hibernate Online Quiz



Following quiz provides Multiple Choice Questions (MCQs) related to Hibernate Framework. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.

Questions and Answers

Answer : A

Explaination

Hibernate is an Object-Relational Mapping(ORM) solution for JAVA.

Q 2 - Is Session a thread-safe object?

A - true

B - false

Answer : B

Explaination

No, Session is not thread-safe.

Q 3 - Session.createQuery creates a new instance of Query for the given HQL query string.

A - true

B - false

Answer : A

Explaination

Session.createQuery creates a new instance of Query for the given HQL query string.

Q 4 - Which method is used to update the state of the given instance from the underlying database?

A - Session.store()

B - Session.keep()

C - Session.update()

D - Session.load()

Answer : C

Explaination

Session.update updates the state of the given instance from the underlying database.

Q 5 - Which element of hbm.xml automatically generate the primary key values?

A - id

B - generator

C - primaryKey

D - None of the above.

Answer : B

Explaination

The <generator> element within the id element is used to automatically generate the primary key values.

Answer : A

Explaination

Lazy loading is a technique in which objects are loaded on demand basis.

Answer : A

Explaination

The second-level cache is the SessionFactory based cache and is mainly responsible for caching objects across sessions.

Answer : C

Explaination

Nonstrict-read-write strategy makes no guarantee of consistency between the cache and the database. Use this strategy if data hardly ever changes and a small likelihood of stale data is not of critical concern.

Q 9 - A Session is used to get a physical connection with a database.

A - true

B - false

Answer : A

Explaination

A Session is used to get a physical connection with a database.

Answer : C

Explaination

By default, the @Id annotation will automatically determine the most appropriate primary key generation strategy to be used but you can override this by applying the @GeneratedValue annotation which takes two parameters strategy and generator.

hibernate_questions_answers.htm
Advertisements