Hibernate Online Quiz


Advertisements


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

Q 1 - Which of the following is not an ORM framework?

A - Castor

B - Spring DAO

C - Hibernate

D - NoSQL

Answer : D

Explaination

NoSQL is not an ORM framework.

Answer : D

Explaination

SessionFactory object configures Hibernate for the application using the supplied configuration file and allows for a Session object to be instantiated. The SessionFactory is a thread safe object and used by all the threads of an application.

Answer : D

Explaination

A new instance of a a persistent class which is not associated with a Session and has no representation in the database and no identifier value is considered transient by Hibernate.

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

A - Session.store()

B - Session.keep()

C - Session.save()

D - Session.load()

Answer : C

Explaination

Session.save saves the state of the given instance from the underlying database.

Q 5 - Which of the following element maps java.util.SortedMap property in hibernate?

A - <set>

B - <list>

C - <bag>

D - <map>

Answer : D

Explaination

This is mapped with a <map> element and initialized with java.util.TreeMap. The sort attribute can be set to either a comparator or natural ordering.

Answer : A

Explaination

Hibernate implements a cache for query resultsets that integrates closely with the second-level cache.

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 - Persistent objects are saved and retrieved through a Session object.

A - false

B - true

Answer : B

Explaination

Persistent objects are saved and retrieved through a Session object.

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