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

A - JDBC

B - SessionFactory

C - Session

D - Configuration

Answer : A

Explaination

JDBC is not a core component of Hibernate.

Answer : D

Explaination

The SessionFactory is heavyweight object so usually it is created during application start up and kept for later use. You would need one SessionFactory object per database using a separate configuration file. So if you are using multiple databases then you would have to create multiple SessionFactory objects.

Answer : A

Explaination

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

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

A - Session.store()

B - Session.keep()

C - Session.save()

D - Session.load()

Answer : C

Explaination

Session.save saves the state of the given instance from the underlying database.

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-many relationship in hibernate?

A - <one-to-many>

B - <one-many>

C - <OneToMany>

D - None of the above.

Answer : A

Explaination

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

Answer : A

Explaination

HQL stands for Hibernate Query Language.

Answer : B

Explaination

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

Answer : A

Explaination

Hibernate Annotations is the powerful way to provide the metadata for the Object and Relational Table mapping. All the metadata is clubbed into the POJO java file along with the code this helps the user to understand the table structure and POJO simultaneously during the development.

Answer : C

Explaination

The @Table annotation allows you to specify the details of the table that will be used to persist the entity in the database. The @Table annotation provides four attributes, allowing you to override the name of the table, its catalogue, and its schema, and enforce unique constraints on columns in the table.


hibernate_questions_answers.htm

Advertisements