基于注解的简单SSH保存用户小案例(3)

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

基于注解的简单SSH保存用户小案例

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/7d585a3e47e45916248b2b654f0df157.html