コード例 #1
0
  @Override
  public Collection<StaffData> retrieveAllStaff(final String extraCriteria) {

    context.authenticatedUser();

    StaffMapper rm = new StaffMapper();
    String sql = "select " + rm.schema();
    if (StringUtils.isNotBlank(extraCriteria)) {
      sql += " where " + extraCriteria;
    }
    sql = sql + " order by s.lastname";
    return this.jdbcTemplate.query(sql, rm, new Object[] {});
  }
コード例 #2
0
  @Override
  public StaffData retrieveStaff(final Long staffId) {

    try {
      context.authenticatedUser();

      StaffMapper rm = new StaffMapper();
      String sql = "select " + rm.schema() + " where s.id = ?";

      StaffData selectedStaff = this.jdbcTemplate.queryForObject(sql, rm, new Object[] {staffId});

      return selectedStaff;
    } catch (EmptyResultDataAccessException e) {
      throw new StaffNotFoundException(staffId);
    }
  }