01: /*
02: * Copyright 2004-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.apache.lucene.store.jdbc.handler;
18:
19: import java.io.IOException;
20: import java.sql.PreparedStatement;
21: import java.util.Iterator;
22: import java.util.List;
23:
24: import org.apache.lucene.store.jdbc.support.JdbcTemplate;
25:
26: /**
27: * Removes file entries from the database by deleting the relevant rows from the database.
28: *
29: * @author kimchy
30: */
31: public class ActualDeleteFileEntryHandler extends
32: AbstractFileEntryHandler {
33:
34: public void deleteFile(final String name) throws IOException {
35: jdbcTemplate.executeUpdate(table.sqlDeleteByName(),
36: new JdbcTemplate.PrepateStatementAwareCallback() {
37: public void fillPrepareStatement(
38: PreparedStatement ps) throws Exception {
39: ps.setFetchSize(1);
40: ps.setString(1, name);
41: }
42: });
43: }
44:
45: public List deleteFiles(final List names) throws IOException {
46: jdbcTemplate.executeBatch(table.sqlDeleteByName(),
47: new JdbcTemplate.PrepateStatementAwareCallback() {
48: public void fillPrepareStatement(
49: PreparedStatement ps) throws Exception {
50: ps.setFetchSize(1);
51: for (Iterator it = names.iterator(); it
52: .hasNext();) {
53: ps.setString(1, (String) it.next());
54: }
55: }
56: });
57: return null;
58: }
59: }
|