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

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.

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

A - true

B - false

Answer : A

Explaination

Session.createSQLQuery creates a new instance of Query for the given SQL query string.

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

A - Session.saveOrUpdate()

B - Session.keep()

C - Session.update()

D - Session.load()

Answer : A

Explaination

Session.saveOrUpdate either saves(Object) or updates(Object) the given instance.

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

A - <set>

B - <list>

C - <bag>

D - <map>

Answer : A

Explaination

java.util.Set property is mapped with a <set> element and initialized with java.util.HashSet.

Answer : A

Explaination

An employee can have multiple certificates and same certificate can be conferred to many employees. Such situation represents many-to-many association.

Answer : D

Explaination

Second level cache is an optional cache and first-level cache will always be consulted before any attempt is made to locate an object in the second-level cache. The second-level cache can be configured on a per-class and per-collection basis and mainly responsible for caching objects across sessions.

Answer : B

Explaination

Use Read-write strategy for read-mostly data where it is critical to prevent stale data in concurrent transactions.

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

HQL queries are translated by Hibernate into conventional SQL queries which in turns perform action on database. The AS clause can be used to assign aliases to the classes in your HQL queries.


hibernate_questions_answers.htm

Advertisements