Spring mvc中一个service中使用多个dao


Spring mvc中一个service中使用多个dao

在当前的一个项目中,一个Service中需要操作多个数据库表,默认是一个service对应一个dao,一个dao对应一个entity,一个entity对应一个表。

    /**
     * Description: 课件服务
     * @author user
     * 2012-5-25
     */ 
    @Component 
    @Transactional 
    public class CourseService extends BaseService<Course> implements ICourseService<Course>{ 
        /** 使用其他dao */ 
        private BaseDao<Student> studentDao; 
         
         
        @Resource(name="studentDao") 
        public void setStudentDao(BaseDao<Student> studentDao) { 
            this.studentDao = studentDao; 
        } 
     
        @Override 
        @Resource(name="courseDao") 
        public void setBaseDao(BaseDao<Course> baseDao) { 
            this.baseDao = baseDao; 
             
        } 
    } 

courseDao是默认使用的dao,studentDao是引进的dao。

猜你喜欢

转载自zhyp29.iteye.com/blog/2366068