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 - Is Session a thread-safe object?

A - true

B - false

Answer : B

Explaination

No, Session is not thread-safe.

Q 3 - Session.createCriteria creates a new Criteria instance, for the given entity class, or a superclass of an entity class.

A - true

B - false

Answer : A

Explaination

Session.createCriteria creates a new Criteria instance, for the given entity class, or a superclass of an entity class.

Q 4 - Which element of hbm.xml defines maps the unique ID attribute in class to the primary key of the database table?

A - id

B - generator

C - primaryKey

D - None of the above.

Answer : A

Explaination

The <id> element maps the unique ID attribute in class to the primary key of the database table.

Answer : D

Explaination

The <property> element is used to map a Java class property to a column in the database table. The name attribute of the 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.

Answer : A

Explaination

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

Q 7 - Is second level caching mandatory in hibernate?

A - true

B - false

Answer : B

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.

Answer : B

Explaination

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

Q 9 - The Session object is lightweight.

A - false

B - true

Answer : B

Explaination

The Session object is lightweight and designed to be instantiated each time an interaction is needed with the database.

Q 10 - length attribute of @Column annotation permits the size of the column used to map a value particularly for a String value.

A - false

B - true

Answer : B

Explaination

length attribute of @Column annotation permits the size of the column used to map a value particularly for a String value.

hibernate_questions_answers.htm
Advertisements