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: PersistentNewDeleted.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 PersistentNewDeleted extends LifeCycleState {
17: protected PersistentNewDeleted() {
18: isPersistent = true;
19: isTransactional = true;
20: isDirty = true;
21: isNew = true;
22: isDeleted = true;
23:
24: stateType = P_NEW_DELETED;
25: }
26:
27: public LifeCycleState transitionMakeNontransactional(
28: StateManagerImpl sm) {
29: throw new JDOUserException(
30: "Cannot make object non-transactional: object is new, deleted and not yet committed",
31: sm.getObject());
32: }
33:
34: public LifeCycleState transitionMakeTransient(StateManagerImpl sm) {
35: throw new JDOUserException(
36: "Cannot make object transient: object is new, deleted, and not yet committed",
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:
53: sm.evictFromTransaction();
54: sm.disconnect();
55: return changeState(sm, TRANSIENT);
56: }
57:
58: public LifeCycleState transitionReadField(StateManagerImpl sm,
59: Transaction tx) {
60: throw new JDOUserException(
61: "Cannot read fields from a deleted object", sm
62: .getObject());
63: }
64:
65: public LifeCycleState transitionWriteField(StateManagerImpl sm,
66: Transaction tx) {
67: throw new JDOUserException(
68: "Cannot write fields to a deleted object", sm
69: .getObject());
70: }
71:
72: public String toString() {
73: return "P_NEW_DELETED";
74: }
75: }
|