Thursday 19 January 2017

How do you configure 2nd level cache in hibernate? What are the ORM levels? Define HibernateTemplate?

How do you configure 2nd level cache in hibernate?
To activate second-level caching, you need to define the hibernate.cache.provider_class property in the hibernate.cfg.xml file as follows: 
<hibernate-configuration>
 <session-factory>
    <property name="hibernate.cache.provider_class">org.hibernate.cache.EHCacheProvider</property>
        </session-factory>
    </hibernate-configuration>
By default, the second-level cache is activated and uses the EHCache provider.

What are the ORM levels?
· Pure relational (stored procedure.)
· Light objects mapping (JDBC)
· Medium object mapping
·Full object Mapping (composition, inheritance, polymorphism, persistence by reachability)

Define HibernateTemplate?
org.springframework.orm.hibernate.HibernateTemplate is a helper class which provides different methods for querying/retrieving data from the database. It also converts checked HibernateExceptions into unchecked DataAccessExceptions.

No comments:

Post a Comment