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

Explaination

ORM stands for Object-Relational Mapping (ORM) is a programming technique for converting data between relational databases.

Answer : D

Explaination

Query objects use SQL or Hibernate Query Language (HQL) string to retrieve data from the database and create objects. A Query instance is used to bind query parameters, limit the number of results returned by the query, and finally to execute the query.

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 method is used to get a persistent instance from the datastore?

A - Session.read()

B - Session.get()

C - Session.retrieve()

D - Session.fetch()

Answer : B

Explaination

Session.get returns the persistent instance of the given named entity with the given identifier, or null if there is no such persistent instance.

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

A - <set>

B - <list>

C - <bag>

D - <map>

Answer : B

Explaination

java.util.List property is mapped with a <list> element and initialized with java.util.ArrayList.

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

A - <many-to-many>

B - <many-many>

C - <ManyToMany>

D - None of the above.

Answer : A

Explaination

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

Answer : A

Explaination

The second-level cache is the SessionFactory based cache and is mainly responsible for caching objects across sessions.

Answer : B

Explaination

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

Q 9 - The SessionFactory is heavyweight object.

A - false

B - true

Answer : B

Explaination

The SessionFactory is heavyweight object so usually it is created during application start up and kept for later use.

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