Currently i am troubling that how to get data from database inside my thread class.
I can't make bean of my thread class because new instance is created of thread on every request.
MyThread.class
class MyThread{
public void run(){
//How to get Employee data.??????
}
}
EmployeeDAO.class
@Component("employeeDAO")
public class EmployeeDAO {
@Cacheable(value = "employeeCache")
public List<Employee> getEmployees() {
//got data from database
return employees;
}
}
Is this good to get context and get dao bean from context and use in every my thread class?
Can you suggest or share code how to solve my above problem?
Aucun commentaire:
Enregistrer un commentaire