1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
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 an instance that was made persistent via reachability within the
24 * current transaction.
25 *
26 * @author Steve Kim
27 * @author: Abe White
28 */
29 class PNewProvisionalState
30 extends PCState {
31
32 void initialize(StateManagerImpl context) {
33 context.setLoaded(true);
34 context.setDirty(true);
35 context.saveFields(false);
36 }
37
38 PCState persist(StateManagerImpl context) {
39 return PNEW;
40 }
41
42 PCState nonprovisional(StateManagerImpl context, boolean logical,
43 OpCallbacks call) {
44 context.preFlush(logical, call);
45 return PNEW;
46 }
47
48 PCState commit(StateManagerImpl context) {
49 return TRANSIENT;
50 }
51
52 PCState commitRetain(StateManagerImpl context) {
53 return TRANSIENT;
54 }
55
56 PCState rollback(StateManagerImpl context) {
57 return TRANSIENT;
58 }
59
60 PCState rollbackRestore(StateManagerImpl context) {
61 context.restoreFields();
62 return TRANSIENT;
63 }
64
65 PCState delete(StateManagerImpl context) {
66 context.preDelete();
67 return TRANSIENT;
68 }
69
70 PCState release(StateManagerImpl context) {
71 return TRANSIENT;
72 }
73
74 boolean isTransactional() {
75 return true;
76 }
77
78 boolean isPersistent() {
79 return true;
80 }
81
82 boolean isNew() {
83 return true;
84 }
85
86 boolean isDirty() {
87 return true;
88 }
89
90 boolean isProvisional() {
91 return true;
92 }
93 }