import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
@Component("myHibernateDaoSupport")
public class MyHibernateDaoSupport extends HibernateDaoSupport {
@Resource(name = "sessionFactory")
public void setSuperSessionFactory(SessionFactory sessionFactory){
super.setSessionFactory(sessionFactory);
}
}
//=================================================
package com.pri.dao.impl;
import com.pri.dao.CustomerDao;
import com.pri.domain.Customer;
import org.springframework.stereotype.Repository;
@Repository("customerDao")
public class CustomerDaoImpl extends MyHibernateDaoSupport implements CustomerDao {
@Override
public void save(Customer customer) {
getHibernateTemplate().save(customer);
}
}
十一、Spring Beans Dependencies