Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
In Hibernate, when interacting with the database, the major interface you need to deal with is the Session interface, which is obtained from the SessionFactory.
Listing 9-12 shows that the ContactDaoImpl class contains the samples in this chapter. The configured Hibernate SessionFactory was injected into the class.
Listing 9-12. Injecting Hibernate SessionFactory
package com.apress.prospring3.ch9.dao.hibernate;
// Import statements omitted
@Repository("contactDao")
@Transactional
public class ContactDaoImpl implements ContactDao {
// Other code omitted
private Log log = LogFactory.getLog(ContactDaoImpl.class);
private SessionFactory sessionFactory;
public SessionFactory getSessionFactory() {
return sessionFactory;
}
@Resource(name="sessionFactory")
public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
}