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.meta;
20:
21: import java.sql.SQLException;
22: import java.util.Map;
23:
24: import org.apache.openjpa.jdbc.kernel.JDBCStore;
25: import org.apache.openjpa.jdbc.sql.Result;
26: import org.apache.openjpa.jdbc.sql.Select;
27: import org.apache.openjpa.jdbc.schema.Column;
28: import org.apache.openjpa.kernel.OpenJPAStateManager;
29: import org.apache.openjpa.kernel.StoreManager;
30:
31: /**
32: * Handles optimistic lock versioning for a class.
33: *
34: * @author Abe White
35: */
36: public interface VersionStrategy extends Strategy {
37:
38: /**
39: * Set the version that uses this strategy. This will be called before use.
40: */
41: public void setVersion(Version owner);
42:
43: /**
44: * Select the data for this indicator.
45: *
46: * @param mapping the known base class being selected; this may
47: * not be the base class in the inheritance hierarchy
48: * @return true if anything was selected; false otherwise
49: */
50: public boolean select(Select sel, ClassMapping mapping);
51:
52: /**
53: * Load data.
54: */
55: public void load(OpenJPAStateManager sm, JDBCStore store, Result res)
56: throws SQLException;
57:
58: /**
59: * This method is called after data is loaded into the instance, in
60: * case the version indicator works off of a state image.
61: */
62: public void afterLoad(OpenJPAStateManager sm, JDBCStore store);
63:
64: /**
65: * Checks the version of the given state manager with the version
66: * stored in memory.
67: *
68: * @return true if the in-memory version was up-to-date, false otherwise
69: */
70: public boolean checkVersion(OpenJPAStateManager sm,
71: JDBCStore store, boolean updateVersion) throws SQLException;
72:
73: /**
74: * @see StoreManager#compareVersion
75: */
76: public int compareVersion(Object v1, Object v2);
77:
78: /**
79: * @return a Map<Column,String> specifying how to update each version
80: * column during a bulk update.
81: *
82: * @since 1.0.0
83: */
84: public Map getBulkUpdateValues();
85: }
|