Hibernate(Engineering > Computer Science And Engineering ) Questions and Answers

Question 1. Which of the following is FALSE about Session in hibernate
  1.    Session is a lightweight non-threadsafe object
  2.    You can share the session between threads
  3.    Session represents a single unit-of-work with the database
  4.    Session is the primary interface for the persistence service
Explanation:-
Answer: Option B. -> You can share the session between threads





Question 2. If a single table hosts all the instances of a class hierarchy, then it is known as
  1.    Joined subclass strategy
  2.    Single table per class hierarchy strategy
  3.    Both
  4.    None
Explanation:-
Answer: Option B. -> Single table per class hierarchy strategy





Question 3. Which of the following is true about query level cache in hibernate?
  1.    Query level cache is an optional feature
  2.    Query level cache requires two additional physical cache regions that hold the cached query results and the timestamps when a table was last updated
  3.    Query level cache is only useful for queries that are run frequently with the same parameters
  4.    All of the above
Explanation:-
Answer: Option D. -> All of the above





Question 4. The QBC stands for
  1.    Query By Call
  2.    Query By Column
  3.    Query By Criteria
  4.    Query By Code
Explanation:-
Answer: Option C. -> Query By Criteria





Question 5. What does the Session object hold?
  1.    First Level Cache
  2.    Second Level Cache
  3.    Both A & B
  4.    None of the above
Explanation:-
Answer: Option A. -> First Level Cache





Question 6. What does hibernate.hbm2ddl.auto create this means?
  1.    create tables automatically
  2.    create session object automatically
  3.    create Session Factory object automatically
  4.    None
Explanation:-
Answer: Option A. -> create tables automatically





Question 7. How many layers are available in Hibernate architecture?
  1.    3
  2.    4
  3.    5
  4.    2
Explanation:-
Answer: Option A. -> 3





Question 8. Which ways are used by the Log4j and Logback frameworks in hibernate framework to support logging?
  1.    By log4j.xml file
  2.    By log4j.properties
  3.    Both A & B
  4.    None of the above
Explanation:-
Answer: Option C. -> Both A & B





Question 9. Select the design pattern that should be followed while creating SessionFactory in hibernate?
  1.    Singleton
  2.    Prototype
  3.    Both
  4.    None
Explanation:-
Answer: Option B. -> Prototype





Question 10. The Hibernate XML configuration file name is?
  1.    hibernate.cfg.xml
  2.    hibernate.config.xml
  3.    hibernate.cg.xml
  4.    None
Explanation:-
Answer: Option A. -> hibernate.cfg.xml