{
SampleDB db = getDatabase();
SampleDB.Employees EMP = db.T_EMPLOYEES;
SampleDB.Departments DEP = db.T_DEPARTMENTS;
DBCommand cmd = db.createCommand();
cmd.select(EMP.C_EMPLOYEE_ID);
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
SearchInfo si = getSearchInfo();
if (si.getDepartmentId()!=null)
cmd.where(EMP.C_DEPARTMENT_ID.is(si.getDepartmentId()));
if (StringUtils.isNotEmpty( si.getFirstName()) )
cmd.where(EMP.C_FIRSTNAME.likeUpper( si.getFirstName()+"%" )
.or(EMP.C_FIRSTNAME.is(null)));
if (StringUtils.isNotEmpty( si.getLastName()) )
cmd.where(EMP.C_LASTNAME.likeUpper( si.getLastName()+"%" ));
cmd.orderBy(EMP.C_LASTNAME);
cmd.orderBy(EMP.C_FIRSTNAME);
// Init BeanList
if (!employeeBeanList.initBeanList(cmd))
{ // Error
return LIST;