public static IApp findApp(String categoryId, String keyword) throws Exception { StringBuffer sql = new StringBuffer(); sql.append("select * from app"); sql.append(" where status=?status"); sql.append(" and isdeleted=?isdeleted"); if (categoryId != null && !categoryId.equals("0")) sql.append(" and categoryId=?categoryId"); if (keyword != null) sql.append(" and appName like ?AppName"); IApp findListing = (IApp) Database.sql(IApp.class, sql.toString()); findListing.set("categoryId", categoryId); findListing.setAppName("%" + keyword + "%"); findListing.setStatus(STATUS_PUBLISHED); findListing.setIsDeleted(false); findListing.select(); return findListing; }