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

Answer : A

Explaination

Hibernate is an Object-Relational Mapping(ORM) solution for JAVA.

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.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 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 element of hbm.xml automatically generate the primary key values?

A - id

B - generator

C - primaryKey

D - None of the above.

Answer : B

Explaination

The <generator> element within the id element is used to automatically generate the primary key values.

Q 6 - Which of the following element is used to represent one-to-one relationship in hibernate?

A - <many-to-one>

B - <many-one>

C - <ManyToOne>

D - None of the above.

Answer : A

Explaination

<many-to-one> element is used to define one-to-one association.

Answer : D

Explaination

HQL takes java objects in the same way as SQL takes tables. HQL is a Object Oriented Query language and is database independent.

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 - A Session is used to get a physical connection with a database.

A - true

B - false

Answer : A

Explaination

A Session is used to get a physical connection with a database.

Answer : A

Explaination

HQL supports INSERT INTO clause only where records can be inserted from one object to another object.

hibernate_questions_answers.htm
Advertisements