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.kernel;
20:
21: /**
22: * Lifecycle state.
23: * Represents a persistent instance that is participating in the current
24: * transaction, and has been modified.
25: *
26: * @author Abe White
27: */
28: class PDirtyState extends PCState {
29:
30: void initialize(StateManagerImpl context) {
31: context.saveFields(false);
32: }
33:
34: void beforeFlush(StateManagerImpl context, boolean logical,
35: OpCallbacks call) {
36: context.preFlush(logical, call);
37: }
38:
39: PCState commit(StateManagerImpl context) {
40: return HOLLOW;
41: }
42:
43: PCState commitRetain(StateManagerImpl context) {
44: return PNONTRANS;
45: }
46:
47: PCState rollback(StateManagerImpl context) {
48: return HOLLOW;
49: }
50:
51: PCState rollbackRestore(StateManagerImpl context) {
52: context.restoreFields();
53: return PNONTRANS;
54: }
55:
56: PCState delete(StateManagerImpl context) {
57: context.preDelete();
58: return PDELETED;
59: }
60:
61: PCState nontransactional(StateManagerImpl context) {
62: return error("dirty", context);
63: }
64:
65: PCState release(StateManagerImpl context) {
66: return error("dirty", context);
67: }
68:
69: boolean isVersionCheckRequired(StateManagerImpl context) {
70: return !context.isFlushed() || context.isFlushedDirty();
71: }
72:
73: PCState afterRefresh() {
74: return PCLEAN;
75: }
76:
77: PCState afterOptimisticRefresh() {
78: return PNONTRANS;
79: }
80:
81: boolean isTransactional() {
82: return true;
83: }
84:
85: boolean isPersistent() {
86: return true;
87: }
88:
89: boolean isDirty() {
90: return true;
91: }
92: }
|