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 2 - Which of the following is not a core component of Hibernate?

A - Transaction

B - Provider

C - Criteria

D - Query

Answer : B

Explaination

Provider is not a core component of Hibernate.

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

A - true

B - false

Answer : B

Explaination

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

Answer : D

Explaination

The <id> element maps the unique ID attribute in class to the primary key of the database table. The name attribute of the id element refers to the property in the class and the column attribute refers to the column in the database table. The type attribute holds the hibernate mapping type, this mapping types will convert from Java to SQL data type.

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

A - <set>

B - <list>

C - <bag>

D - <map>

Answer : D

Explaination

java.util.Map property is mapped with a <map> element and initialized with java.util.HashMap.

Q 6 - Child objects are not loaded when parent is loaded/populated from database. What this technique is called?

A - Eager Loading

B - Lazy Loading

C - Request based Loading

D - None of the above.

Answer : B

Explaination

In lazy loading child objects are not loaded when parent is loaded.

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

Hibernate supports named parameters in its HQL queries. HQL supports a range of aggregate methods, similar to SQL.

hibernate_questions_answers.htm
Advertisements