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: TransientDirty.java,v 1.1 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 TransientDirty extends LifeCycleState {
17: protected TransientDirty() {
18: isPersistent = false;
19: isTransactional = true;
20: isDirty = true;
21: isNew = false;
22: isDeleted = false;
23:
24: stateType = T_DIRTY;
25: }
26:
27: public LifeCycleState transitionMakePersistent(StateManagerImpl sm,
28: Transaction tx) {
29: return changeState(sm, P_NEW);
30: }
31:
32: public LifeCycleState transitionDeletePersistent(
33: StateManagerImpl sm, Transaction tx) {
34: throw new JDOUserException(
35: "Cannot delete, object is not persistent", sm
36: .getObject());
37: }
38:
39: public LifeCycleState transitionMakeNontransactional(
40: StateManagerImpl sm) {
41: throw new JDOUserException(
42: "Cannot make object non-transactional: object is dirty",
43: sm.getObject());
44: }
45:
46: public LifeCycleState transitionCommit(StateManagerImpl sm,
47: Transaction tx) {
48: sm.discardSavedFields();
49: sm.evictFromTransaction();
50: return changeState(sm, T_CLEAN);
51: }
52:
53: public LifeCycleState transitionRollback(StateManagerImpl sm,
54: Transaction tx) {
55: sm.restoreFields();
56: sm.replaceSCOFields();
57: sm.evictFromTransaction();
58: return changeState(sm, T_CLEAN);
59: }
60:
61: public String toString() {
62: return "T_DIRTY";
63: }
64: }
|