01: /*
02: * Copyright 2004 (C) TJDO.
03: * All rights reserved.
04: *
05: * This software is distributed under the terms of the TJDO License version 1.0.
06: * See the terms of the TJDO License in the documentation provided with this software.
07: *
08: * $Id: PersistentDeleted.java,v 1.6 2004/01/18 03:01:06 jackknifebarber Exp $
09: */
10:
11: package com.triactive.jdo.state;
12:
13: import javax.jdo.JDOUserException;
14: import javax.jdo.Transaction;
15:
16: class PersistentDeleted extends LifeCycleState {
17: protected PersistentDeleted() {
18: isPersistent = true;
19: isTransactional = true;
20: isDirty = true;
21: isNew = false;
22: isDeleted = true;
23:
24: stateType = P_DELETED;
25: }
26:
27: public LifeCycleState transitionMakeNontransactional(
28: StateManagerImpl sm) {
29: throw new JDOUserException(
30: "Cannot make object non-transactional: object has been deleted",
31: sm.getObject());
32: }
33:
34: public LifeCycleState transitionMakeTransient(StateManagerImpl sm) {
35: throw new JDOUserException(
36: "Cannot make object transient: object has been deleted",
37: sm.getObject());
38: }
39:
40: public LifeCycleState transitionCommit(StateManagerImpl sm,
41: Transaction tx) {
42: sm.clearPersistentFields();
43: sm.evictFromTransaction();
44: sm.disconnect();
45: return changeState(sm, TRANSIENT);
46: }
47:
48: public LifeCycleState transitionRollback(StateManagerImpl sm,
49: Transaction tx) {
50: if (tx.getRestoreValues()) {
51: sm.restoreFields();
52: sm.replaceSCOFields();
53: sm.evictFromTransaction();
54: return changeState(sm, P_NONTRANS);
55: } else {
56: sm.clearPersistentFields();
57: sm.discardSavedFields();
58: sm.evictFromTransaction();
59: return changeState(sm, HOLLOW);
60: }
61:
62: }
63:
64: public LifeCycleState transitionReadField(StateManagerImpl sm,
65: Transaction tx) {
66: throw new JDOUserException(
67: "Cannot read fields from a deleted object", sm
68: .getObject());
69: }
70:
71: public LifeCycleState transitionWriteField(StateManagerImpl sm,
72: Transaction tx) {
73: throw new JDOUserException(
74: "Cannot write fields to a deleted object", sm
75: .getObject());
76: }
77:
78: public String toString() {
79: return "P_DELETED";
80: }
81: }
|