Wednesday, April 3, 2019

Hibernate interview questions part-1

1. Is hibernate support inheritance  ?
Answer:- Yes.

2. What is inheritance in hibernate ? 

3. what is association in hibernate ? 
Answer :- 

4. How to configure hibernate with spring boot ? 
Answer :- 

5. How to connect two database in spring boot application ?

6. What are the interfaces used in to hibernate ?

There are below mentioned interface in hibernate.

  • Session Interface : 
  • SessionFactory Interface
  • Configuration Interface : To configure and bootstrap hibernate.
  • Transaction Interface
  • Query and Criteria Interface

7. First level cache Vs Second level cache in hibernate ? 

First-level cache is associates with the Session object. it is by default enabled.

Second level cache is associated with SessionFactory. It is global for all the session objects and not enabled by default

we need to enabled second level cache by setting property.

<property name="cache.use_second_level_cache">true</property>   
<property name="cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</property> 

There are different vendors who provided the implementation of Second Level Cache.

  • EH Cache
  • OS Cache
  • Swarm Cache
  • JBoss Cache
8. Is hibernate support inheritance ?
Answer : Yes

9. Type of inheritance in hibernate ?
Answer : There are 3 types of inheritance in hibernate.
  • Table per concrete class.
  • Table per class hierarchy.
  • Table per subclass.
10. What is Detached Criteria in hibernate ?
Answer:- DetachedCriteria is a way, when the hibernate session is not present. we can use detached criteria to writing query in detached mode. You can instantiate this class anywhere. when we have session available.

Related Tutorials


  1. Q1- Is hibernate support in heritance ?

    There is a type in Q1. in heritance should be inheritance