@Test public void testDeleteAllOccurences() { final ScopePathBuilderFactory factory = getConfigService().getScopePathBuilderFactory(TestConfiguration.class); final ComplexConfigDTO config1 = createTestConfigDTO(factory.annotatedPathUntil(DefaultScopeDescriptor.NAME).create()); persister.saveConfiguration(config1); final ComplexConfigDTO config2 = createTestConfigDTO(factory.annotatedPathUntil(GlobalScopeDescriptor.NAME).create()); persister.saveConfiguration(config2); final ComplexConfigDTO config3 = createTestConfigDTO(factory.annotatedPath().create()); persister.saveConfiguration(config3); persister.deleteAllOccurences("global", new HashMap<String, String>()); Assert.assertNull(persister.loadConfiguration(factory.annotatedPathUntil(GlobalScopeDescriptor.NAME).create())); Assert.assertNull(persister.loadConfiguration(factory.annotatedPath().create())); Assert.assertEquals( config1, persister.loadConfiguration(factory.annotatedPathUntil(DefaultScopeDescriptor.NAME).create())); }
@Override public void deleteAllOccurences(final String scopeName, final Map<String, String> properties) { Assert.paramNotNull(scopeName, "scopeName"); Assert.paramNotNull(properties, "properties"); new JdbcTemplate<ResultSet>(dataSource).perform(new DbCallable() { @Override public Object execute(final Connection con) throws Exception { PreparedStatement stmt = null; final String searchedPathPart = gen.buildScopeWithProperty(scopeName, properties); try { stmt = con.prepareStatement(queryGen.createDeleteLikeItemQuery( configTableName, scopePathColumnName, searchedPathPart)); stmt.executeUpdate(); } catch (final SQLException e) { throw new StoreConfigException("Error while deleting configurations with path'" + searchedPathPart + "'!", e); } finally { dbUtils.closeQuietly(stmt); } return null; } }); }
DbConfigPersister implements ConfigPersister { @Override public void deleteAllOccurences(final String scopeName, final Map<String, String> properties) { Assert.paramNotNull(scopeName, "scopeName"); Assert.paramNotNull(properties, "properties"); new JdbcTemplate<ResultSet>(dataSource).perform(new DbCallable() { @Override public Object execute(final Connection con) throws Exception { PreparedStatement stmt = null; final String searchedPathPart = gen.buildScopeWithProperty(scopeName, properties); try { stmt = con.prepareStatement(queryGen.createDeleteLikeItemQuery( configTableName, scopePathColumnName, searchedPathPart)); stmt.executeUpdate(); } catch (final SQLException e) { throw new StoreConfigException("Error while deleting configurations with path'" + searchedPathPart + "'!", e); } finally { dbUtils.closeQuietly(stmt); } return null; } }); } }
DbConfigPersister implements ConfigPersister { @Override public void deleteAllOccurences(final String scopeName, final Map<String, String> properties) { Assert.paramNotNull(scopeName, "scopeName"); Assert.paramNotNull(properties, "properties"); new JdbcTemplate<ResultSet>(dataSource).perform(new DbCallable() { @Override public Object execute(final Connection con) throws Exception { PreparedStatement stmt = null; final String searchedPathPart = gen.buildScopeWithProperty(scopeName, properties); try { stmt = con.prepareStatement(queryGen.createDeleteLikeItemQuery( configTableName, scopePathColumnName, searchedPathPart)); stmt.executeUpdate(); } catch (final SQLException e) { throw new StoreConfigException("Error while deleting configurations with path'" + searchedPathPart + "'!", e); } finally { dbUtils.closeQuietly(stmt); } return null; } }); } DbConfigPersister(
		final String configTableName,
		final String scopePathColumnName,
		final String configVersionColumnName,
		final String configColumnName,
		final ConfigMarshaller marshaller,
		final DataSource dataSource); }
DbConfigPersister implements ConfigPersister { @Override public void deleteAllOccurences(final String scopeName, final Map<String, String> properties) { Assert.paramNotNull(scopeName, "scopeName"); Assert.paramNotNull(properties, "properties"); new JdbcTemplate<ResultSet>(dataSource).perform(new DbCallable() { @Override public Object execute(final Connection con) throws Exception { PreparedStatement stmt = null; final String searchedPathPart = gen.buildScopeWithProperty(scopeName, properties); try { stmt = con.prepareStatement(queryGen.createDeleteLikeItemQuery( configTableName, scopePathColumnName, searchedPathPart)); stmt.executeUpdate(); } catch (final SQLException e) { throw new StoreConfigException("Error while deleting configurations with path'" + searchedPathPart + "'!", e); } finally { dbUtils.closeQuietly(stmt); } return null; } }); } DbConfigPersister(
		final String configTableName,
		final String scopePathColumnName,
		final String configVersionColumnName,
		final String configColumnName,
		final ConfigMarshaller marshaller,
		final DataSource dataSource); @Override String getId(); @Override ComplexConfigDTO loadConfiguration(final ScopePath scopePath); @Override void saveConfiguration(final ComplexConfigDTO configDTO); @Override void updateConfiguration(final ComplexConfigDTO configDTO); @Override void delete(final ScopePath scope, final boolean deleteChildren); @Override void deleteAllOccurences(final String scopeName, final Map<String, String> properties); @Override Collection<ScopePath> listScopes(final String scopeName, final Map<String, String> properties); }
DbConfigPersister implements ConfigPersister { @Override public void deleteAllOccurences(final String scopeName, final Map<String, String> properties) { Assert.paramNotNull(scopeName, "scopeName"); Assert.paramNotNull(properties, "properties"); new JdbcTemplate<ResultSet>(dataSource).perform(new DbCallable() { @Override public Object execute(final Connection con) throws Exception { PreparedStatement stmt = null; final String searchedPathPart = gen.buildScopeWithProperty(scopeName, properties); try { stmt = con.prepareStatement(queryGen.createDeleteLikeItemQuery( configTableName, scopePathColumnName, searchedPathPart)); stmt.executeUpdate(); } catch (final SQLException e) { throw new StoreConfigException("Error while deleting configurations with path'" + searchedPathPart + "'!", e); } finally { dbUtils.closeQuietly(stmt); } return null; } }); } DbConfigPersister(
		final String configTableName,
		final String scopePathColumnName,
		final String configVersionColumnName,
		final String configColumnName,
		final ConfigMarshaller marshaller,
		final DataSource dataSource); @Override String getId(); @Override ComplexConfigDTO loadConfiguration(final ScopePath scopePath); @Override void saveConfiguration(final ComplexConfigDTO configDTO); @Override void updateConfiguration(final ComplexConfigDTO configDTO); @Override void delete(final ScopePath scope, final boolean deleteChildren); @Override void deleteAllOccurences(final String scopeName, final Map<String, String> properties); @Override Collection<ScopePath> listScopes(final String scopeName, final Map<String, String> properties); static final String ID; }