Ejemplo n.º 1
0
 private ServicePrice constructPriceEntity(ResultSet rs) throws SQLException {
   ServicePrice servicePrice = new ServicePrice();
   servicePrice.setPrice(rs.getBigDecimal("price"));
   servicePrice.setServiceId(rs.getInt("service_id"));
   servicePrice.setDate(rs.getDate("date").toLocalDate());
   return servicePrice;
 }
Ejemplo n.º 2
0
  public List<ServicePrice> getServicePricesByServiceId(int serviceId) {
    List<ServicePrice> servicePrices = new ArrayList<>();
    try {
      PreparedStatement preparedStatement =
          getConnection()
              .prepareStatement("SELECT * FROM \"service_price\" where \"service_id\" = ?");
      preparedStatement.setInt(1, serviceId);
      ResultSet rs = preparedStatement.executeQuery();
      while (rs.next()) {
        ServicePrice servicePrice = new ServicePrice();
        servicePrice.setServiceId(rs.getInt("service_id"));
        servicePrice.setPrice(rs.getBigDecimal("price"));
        servicePrice.setDate(rs.getDate("date").toLocalDate());
        servicePrices.add(servicePrice);
      }

    } catch (SQLException ex) {
      ex.printStackTrace();
      throw new DAOException();
    }

    return servicePrices;
  }