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

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.

Answer : D

Explaination

A new instance of a a persistent class which is not associated with a Session and has no representation in the database and no identifier value is considered transient by Hibernate.

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.

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

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