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

Q 1 - Which of the following database is not supported by Hibernate?

A - DB2/NT

B - MySQL

C - FoundationDB

D - PostgreSQL

Answer : C

Explaination

FoundationDB is a NoSQL database and is not supported by Hibernate.

Answer : D

Explaination

Query objects use SQL or Hibernate Query Language (HQL) string to retrieve data from the database and create objects. A Query instance is used to bind query parameters, limit the number of results returned by the query, and finally to execute the query.

Answer : A

Explaination

This property makes Hibernate generate the appropriate SQL for the chosen database.

Answer : D

Explaination

The <class> elements are used to define specific mappings from a Java classes to the database tables. The Java class name is specified using the name attribute of the class element and the database table name is specified using the table attribute.

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 : C

Explaination

save saves the object and returns the id of the instance whereas persist do not return anything after saving the instance.

Answer : D

Explaination

The first-level cache is the Session cache and is a mandatory cache through which all requests must pass. The Session object keeps an object under its own power before committing it to the database.

Answer : C

Explaination

Read-only concurrency strategy is suitable for data which never changes. Use it for reference data only.

Q 9 - You would need one SessionFactory object per database using a separate configuration file.

A - false

B - true

Answer : B

Explaination

You would need one SessionFactory object per database using a separate configuration file.

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