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 an instance that was made persistent, then deleted within the
24: * current transaction.
25: *
26: * @author Abe White
27: */
28: class PNewDeletedState extends PCState {
29:
30: PCState commit(StateManagerImpl context) {
31: context.clearFields();
32: return TRANSIENT;
33: }
34:
35: PCState commitRetain(StateManagerImpl context) {
36: context.clearFields();
37: return TRANSIENT;
38: }
39:
40: PCState rollback(StateManagerImpl context) {
41: return TRANSIENT;
42: }
43:
44: PCState rollbackRestore(StateManagerImpl context) {
45: context.restoreFields();
46: return TRANSIENT;
47: }
48:
49: PCState persist(StateManagerImpl context) {
50: context.eraseFlush();
51: return PNEW;
52: }
53:
54: PCState nontransactional(StateManagerImpl context) {
55: return error("deleted", context);
56: }
57:
58: PCState release(StateManagerImpl context) {
59: return error("deleted", context);
60: }
61:
62: PCState beforeWrite(StateManagerImpl context, int field,
63: boolean mutate) {
64: return error("deleted", context);
65: }
66:
67: PCState beforeOptimisticWrite(StateManagerImpl context, int field,
68: boolean mutate) {
69: return error("deleted", context);
70: }
71:
72: boolean isTransactional() {
73: return true;
74: }
75:
76: boolean isPersistent() {
77: return true;
78: }
79:
80: boolean isNew() {
81: return true;
82: }
83:
84: boolean isDeleted() {
85: return true;
86: }
87:
88: boolean isDirty() {
89: return true;
90: }
91: }
|