I see some Spring-MVC projects which have EntityDAO, EntityDAOImpl and EntityService. I don't understand what's the different between them.
For example, I have a user
entity.
public Class UserEntity {
private int userId;
private String userName;
private String userInfo;
// getter and setter
}
The UserDAO:
@Repository
public interface UserDAO {
@Select({"SELECT * FROM user WHERE id=#{id};"})
UserEntity getById(final int id);
}
The UserDAOImpl:
@Repository
public class UserDAOImpl implements UserDAO {
@Autowired
private UserDAO userDAO;
@Override
public UserEntity getById(int id) {
return userDAO.getById(id);
}
}
The UserService:
@Service
public class UserService {
@Autowired
private UserDAOImpl UserDAO;
public UserEntity getById(int id) {
return userDAO.getByid(id);
}
}
So, I think using UserDAOImpl is enough, why should I need UserService?