@Override public List<BlockStatus> findAllByBlockStatusExample( BlockStatusExample blockStatusExample, int offset, int limit) throws DaoException { try { Connection conn = DataSourceUtils.doGetConnection(dataSource); Statement stmt = conn.createStatement(); String clause = BlockStatusDaoImpl.buildClause(blockStatusExample) + " limit " + offset + "," + limit; logger.debug( "DB:FIND block_status[distinct=" + blockStatusExample.isDistinct() + ",clause=" + clause + "]"); ResultSet rs = stmt.executeQuery( "select" + (blockStatusExample.isDistinct() ? " distinct " : " ") + "`id`,`id2`,`shipment_id`,`declaration_no`,`status`,`remark`,`block_date_time`,`unblock_date_time`,`company_code`,`company_type`,`user_block`,`mawb`,`hawb`,`flight_no`,`flight_date`,`user_unblock`,`modified_date_time`,`auto_block_profile_id` from block_status" + clause); List<BlockStatus> list = new ArrayList<BlockStatus>(); while (rs.next()) { list.add(BlockStatusDaoImpl.createInstanceFromResultSet(rs)); } rs.close(); stmt.close(); return list; } catch (Exception e) { throw new DaoException(e); } }
@Override public int countByBlockStatusExample(BlockStatusExample blockStatusExample) throws DaoException { try { Connection conn = DataSourceUtils.doGetConnection(dataSource); Statement stmt = conn.createStatement(); String clause = BlockStatusDaoImpl.buildClause(blockStatusExample); ResultSet rs = stmt.executeQuery( "select" + (blockStatusExample.isDistinct() ? " distinct " : " ") + "count(*) from block_status" + clause); int count = -1; if (rs.next()) { count = rs.getInt(1); } rs.close(); stmt.close(); logger.debug( "DB:COUNT block_status[distinct=" + blockStatusExample.isDistinct() + ",clause=" + clause + "] => " + count); return count; } catch (Exception e) { throw new DaoException(e); } }