cmd.select(C_FULL_NAME, EMP.C_GENDER, EMP.C_DATE_OF_BIRTH);
cmd.select(C_DEPARTMENT);
cmd.join(DEP.C_DEPARTMENT_ID, EMP.C_DEPARTMENT_ID);
// Set filter constraints
EmployeeSearch employeeSearch = (EmployeeSearch) FacesUtils
.getManagedBean(EmployeeSearch.class);
if (employeeSearch.getDepartmentId() != null)
cmd.where(EMP.C_DEPARTMENT_ID.is(employeeSearch.getDepartmentId()));
if (StringUtils.isValid(employeeSearch.getFirstName()))
cmd.where(EMP.C_FIRST_NAME.likeUpper(
employeeSearch.getFirstName() + "%").or(
EMP.C_FIRST_NAME.is(null)));
if (StringUtils.isValid(employeeSearch.getLastName()))
cmd.where(EMP.C_LAST_NAME.likeUpper(employeeSearch.getLastName()
+ "%"));
cmd.orderBy(EMP.C_LAST_NAME);
cmd.orderBy(EMP.C_FIRST_NAME);