SqlHandler { public <K, V> PdxInstance read(Region<K, V> region, K key) throws SQLException { if (key == null) { throw new IllegalArgumentException("Key for query cannot be null"); } PdxInstance result; try (Connection connection = getConnection()) { EntryColumnData entryColumnData = getEntryColumnData(tableMetaData, key, null, Operation.GET); try (PreparedStatement statement = getPreparedStatement(connection, tableMetaData, entryColumnData, Operation.GET)) { try (ResultSet resultSet = executeReadQuery(statement, entryColumnData)) { result = getSqlToPdxInstance().create(resultSet); } } } return result; } SqlHandler(InternalCache cache, String regionName,
      TableMetaDataManager tableMetaDataManager, JdbcConnectorService configService,
      DataSourceFactory dataSourceFactory);  SqlHandler(InternalCache cache, String regionName,
      TableMetaDataManager tableMetaDataManager, JdbcConnectorService configService); PdxInstance read(Region<K, V> region, K key); void write(Region<K, V> region, Operation operation, K key, PdxInstance value);  }
@Test public void readThrowsIfNoKeyProvided() { assertThatThrownBy(() -> handler.read(region, null)) .isInstanceOf(IllegalArgumentException.class); }
@Test public void readClosesPreparedStatementWhenFinished() throws Exception { setupEmptyResultSet(); Object getKey = "getkey"; handler.read(region, getKey); verify(statement).executeQuery(); verify(statement).setObject(1, getKey); verify(statement).close(); }
@Test public void throwsExceptionIfQueryFails() throws Exception { when(statement.executeQuery()).thenThrow(SQLException.class); assertThatThrownBy(() -> handler.read(region, new Object())).isInstanceOf(SQLException.class); }