@PostConstruct void populateCache() { LOG.info("Populating merchants cache..."); String sql = "select * " + "from MERCHANT"; try (Connection connection = dataSource.getConnection(); PreparedStatement statement = connection.prepareStatement(sql)) { try (ResultSet resultSet = statement.executeQuery()) { if (resultSet.next()) { Merchant merchant = readMerchantFrom(resultSet); cache.put(merchant.getNumber(), merchant); } } } catch (SQLException e) { throw new RuntimeException("Error in findByNumber!", e); } }
void populateCache() { LOG.info("Populating merchants cache..."); String sql = "select * " + "from MERCHANT"; try (Connection connection = dataSource.getConnection(); PreparedStatement statement = connection.prepareStatement(sql)) { try (ResultSet resultSet = statement.executeQuery()) { if (resultSet.next()) { Merchant merchant = readMerchantFrom(resultSet); cache.put(merchant.getNumber(), merchant); } } } catch (SQLException e) { throw new RuntimeException("Error in findByNumber!", e); } }
@PostConstruct void populateCache() { LOG.info("Populating merchants cache..."); String sql = "select * " + "from MERCHANT"; try (Connection connection = dataSource.getConnection(); PreparedStatement statement = connection.prepareStatement(sql)) { try (ResultSet resultSet = statement.executeQuery()) { if (resultSet.next()) { Merchant merchant = readMerchantFrom(resultSet); cache.put(merchant.getNumber(), merchant); } } } catch (SQLException e) { throw new RuntimeException("Error in findByNumber!", e); } }
@PostConstruct void populateCache() { LOG.info("Populating merchants cache..."); String sql = "select * " + "from MERCHANT"; try (Connection connection = dataSource.getConnection(); PreparedStatement statement = connection.prepareStatement(sql)) { try (ResultSet resultSet = statement.executeQuery()) { if (resultSet.next()) { Merchant merchant = readMerchantFrom(resultSet); cache.put(merchant.getNumber(), merchant); } } } catch (SQLException e) { throw new RuntimeException("Error in findByNumber!", e); } }
@PostConstruct void populateCache() { LOG.info("Populating merchants cache..."); String sql = "select * " + "from MERCHANT"; try (Connection connection = dataSource.getConnection(); PreparedStatement statement = connection.prepareStatement(sql)) { try (ResultSet resultSet = statement.executeQuery()) { if (resultSet.next()) { Merchant merchant = readMerchantFrom(resultSet); cache.put(merchant.getNumber(), merchant); } } } catch (SQLException e) { throw new RuntimeException("Error in findByNumber!", e); } }
@PostConstruct void populateCache() { LOG.info("Populating merchants cache..."); String sql = "select * " + "from MERCHANT"; try (Connection connection = dataSource.getConnection(); PreparedStatement statement = connection.prepareStatement(sql)) { try (ResultSet resultSet = statement.executeQuery()) { if (resultSet.next()) { Merchant merchant = readMerchantFrom(resultSet); cache.put(merchant.getNumber(), merchant); } } } catch (SQLException e) { throw new RuntimeException("Error in findByNumber!", e); } }
@Override public Merchant findByNumber(String number) { String sql = "select * " + "from MERCHANT m " + "where m.NUMBER = ?"; try (Connection connection = dataSource.getConnection(); PreparedStatement statement = connection.prepareStatement(sql)) { statement.setString(1, number); try (ResultSet resultSet = statement.executeQuery()) { if (resultSet.next()) { return readMerchantFrom(resultSet); } } } catch (SQLException e) { throw new RuntimeException("Error in findByNumber!", e); } throw new EmptyResultDataAccessException(1); }