Practice Hibernate MCQs with Detailed Explanations
Answer at least
12
questions to submit.
1.
What does the Session object hold?
Correct answer:First Level Cache
2.
Which ways are used by the Log4j and Logback frameworks in hibernate framework to support logging?
Correct answer:Both A & B
3.
In case of Table per Concrete class, there will be three tables in the database having no relations to each other. Which are the ways to map the table?
Correct answer:Both A & B
4.
Which of these simplifies an Object Relational Mapping tool?
Correct answer:All mentioned above
5.
What is dirty checking in Hibernate?
Correct answer:check the data when insert into data base.
Dirty checking feature of the Hibernate allows users or developers to avoid time consuming data base write actions. This feature makes necessary updations and changes to the fields which require a change, remaining fields are left unchanged or untouched.
6.
What does session.evict() method do?
Correct answer:remove the object and its collections from the first level cache
7.
Which statement is correct?
Correct answer:Only the Session that you obtained with sf.getCurrentSession() is flushed and closed automatically
8.
what does hibernate.hbm2ddl.auto create this means?
Correct answer:create tables automatically
9.
Is Hibernate Session threadsafe?
Correct answer:No
Session object is not thread-safe in Hibernate and intended to be used with-in single thread in the application.
10.
How can you make a property be read from the database but not modified in anyway?
Correct answer:By using the insert="false" and update="false" attributes.
11.
which 2nd level cache is better in hibernate?
Correct answer:EHCache
12.
In the elements of Hibernate architecture is a factory of session and client of ConnectionProvider,It holds second level cache (optional) of data?
Correct answer:SessionFactory
13.
Which of the following are most common configuration methods of Hibernate Configuation
Correct answer:Mapping files
14.
Which of the following is FALSE about Session in hibernate?
Correct answer:Session is a light weight non-threadsafe object.
15.
There are core interfaces are used in just about every Hibernate application. Using these interfaces, you can store and retrieve persistent objects and control transactions?
A. Configuration interface
B. Session interface
C. Query and Criteria interfaces
D. User Interface
E. Configuration interface
Correct answer:A, B, C, E
16.
Which of the following is not a Session method?
Correct answer:Session.remove()
17.
Which of the following is NOT a best practice for defining your Hibernate persistent classes?
Correct answer:The persistent class should be final because if it is final then lazy loading can be used by creating proxy objects.