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

A Session is used to get a physical connection with a database. The Session object is lightweight and designed to be instantiated each time an interaction is needed with the database. Persistent objects are saved and retrieved through a Session object.

Q 3 - Which method is used to remove a persistent instance from the datastore?

A - Session.delete()

B - Session.remove()

C - Session.del()

D - Session.rm()

Answer : A

Explaination

Session.delete() removes a persistent instance from the datastore.

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

A - Session.refresh()

B - Session.get()

C - Session.reload()

D - Session.retrieve()

Answer : A

Explaination

Session.refresh re-reads the state of the given instance from the underlying database.

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

A - <set>

B - <list>

C - <bag>

D - <map>

Answer : D

Explaination

This is mapped with a <map> element and initialized with java.util.TreeMap. The sort attribute can be set to either a comparator or natural ordering.

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

HQL stands for Hibernate Query Language.

Answer : D

Explaination

All of the above are true with respect to ORM vs JDBC.

Q 9 - You would need one SessionFactory object per database using a separate configuration file.

A - false

B - true

Answer : B

Explaination

You would need one SessionFactory object per database using a separate configuration file.

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