I have a method which will called from ManagedBean as follows
getemployeeService().findEmployees(qData);
qData is nothing but a class for passing parameters for lazyload load method.
EmployeeQueryData qData = new EmployeeQueryData(start, end, sortField, order, filters);
I would like to pass one for parameter to findEmployees method in DAO class for getting employees based on deptNo.
My doubt is should I pass another parameter like
getemployeeService().findEmployees(qData, String deptNo);
or pass Employees class as
getemployeeService().findEmployees(qData, Employees emp);
and in DAO I invoke deptNo as
emp.getDeptNo
What is the best approach and practice? Any suggestions and insight are highly appreciable.
I think that passing department makes more sense. Because when we say DAO layer we look only in the perspective that is has to deal with data. We should include emp.getDeptNo() in business logic tier.
But talking about extensibility, if future you may want to send some other params say dept,DOJ and so on. So in that case you can create another class say Criteria and place params field in that class and pass Object of this class to find() method.