01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19: package org.apache.openjpa.jdbc.sql;
20:
21: import java.sql.SQLException;
22:
23: import org.apache.openjpa.jdbc.schema.Table;
24: import org.apache.openjpa.kernel.OpenJPAStateManager;
25:
26: /**
27: * Manages rows during an insert/update/delete process. Row managers
28: * do not have to be threadsafe.
29: *
30: * @author Abe White
31: */
32: public interface RowManager {
33:
34: /**
35: * Return the row for the given table and owner object, or null if
36: * <code>create</code> is false and the row has not already been created.
37: * The action must be one of {@link Row#ACTION_INSERT},
38: * {@link Row#ACTION_UPDATE}, {@link Row#ACTION_DELETE}.
39: */
40: public Row getRow(Table table, int action, OpenJPAStateManager sm,
41: boolean create);
42:
43: /**
44: * Return a row for the given secondary table.
45: * The action must be one of {@link Row#ACTION_INSERT},
46: * {@link Row#ACTION_UPDATE}, {@link Row#ACTION_DELETE}.
47: * Note that secondary rows are not considered when creating the foreign
48: * key dependency graph, with can cause constraint violations when using
49: * the <code>UPDATE</code> action. Only use this action if the secondary
50: * row does not have restrict-action foreign keys. Otherwise use both
51: * a delete and then an insert to perform the update.
52: */
53: public Row getSecondaryRow(Table table, int action);
54:
55: /**
56: * Flush the secondary row; after flushing the row is available for reuse.
57: * It will retain all previously set values.
58: */
59: public void flushSecondaryRow(Row row) throws SQLException;
60:
61: /**
62: * Return a logical row representing an update that should be made to
63: * all rows of the given table. The action must be one of
64: * {@link Row#ACTION_UPDATE}, {@link Row#ACTION_DELETE}.
65: */
66: public Row getAllRows(Table table, int action);
67:
68: /**
69: * Flush the logical row.
70: */
71: public void flushAllRows(Row row) throws SQLException;
72: }
|