javahibernatecachinghibernate-5.x

Hibernate Migration from 4.3.x to 5.x for method org.hibernate.cache.spi.GeneralDataRegion.get(Object key)


In Hibernate 4.3.x, there is a method

org.hibernate.cache.spi.GeneralDataRegion.get(Object key)

But in Hibernate 5.x, this method signature is changed to

org.hibernate.cache.spi.GeneralDataRegion.get(SessionImplementor session, Object key)

Similarly new put method signature in Hibernate-5 is as follows :

public void put(SessionImplementor session, Object key, Object value)

Here what is SessionImplementor class and how to get its object? i.e., What will be the code substitution in Hibernate-5?


Solution

  • I think following line gives SessionImplementor object:

    SessionImplementor hibernateSession=((SessionImplementor)sessionFactory.getCurrentSession());