1 10 11 package com.triactive.jdo.state; 12 13 import javax.jdo.Transaction; 14 15 16 class PersistentClean extends LifeCycleState 17 { 18 protected PersistentClean() 19 { 20 isPersistent = true; 21 isTransactional = true; 22 isDirty = false; 23 isNew = false; 24 isDeleted = false; 25 26 stateType = P_CLEAN; 27 } 28 29 public LifeCycleState transitionDeletePersistent(StateManagerImpl sm, Transaction tx) 30 { 31 sm.preDelete(); 32 return changeState(sm, P_DELETED); 33 } 34 35 public LifeCycleState transitionMakeNontransactional(StateManagerImpl sm) 36 { 37 sm.evictFromTransaction(); 38 return changeState(sm, P_NONTRANS); 39 } 40 41 public LifeCycleState transitionMakeTransient(StateManagerImpl sm) 42 { 43 sm.evictFromTransaction(); 44 sm.disconnect(); 45 return changeState(sm, TRANSIENT); 46 } 47 48 public LifeCycleState transitionCommit(StateManagerImpl sm, Transaction tx) 49 { 50 if (tx.getRetainValues()) 51 { 52 sm.evictFromTransaction(); 53 return changeState(sm, P_NONTRANS); 54 } 55 else 56 { 57 sm.clearPersistentFields(); 58 sm.evictFromTransaction(); 59 return changeState(sm, HOLLOW); 60 } 61 } 62 63 public LifeCycleState transitionRollback(StateManagerImpl sm, Transaction tx) 64 { 65 if (tx.getRestoreValues()) 66 { 67 sm.evictFromTransaction(); 68 return changeState(sm, P_NONTRANS); 69 } 70 else 71 { 72 sm.clearPersistentFields(); 73 sm.evictFromTransaction(); 74 return changeState(sm, HOLLOW); 75 } 76 } 77 78 public LifeCycleState transitionEvict(StateManagerImpl sm) 79 { 80 sm.clearPersistentFields(); 81 sm.evictFromTransaction(); 82 return changeState(sm, HOLLOW); 83 } 84 85 public LifeCycleState transitionWriteField(StateManagerImpl sm, Transaction tx) 86 { 87 if (tx.getRestoreValues()) 88 sm.saveFields(); 89 90 return changeState(sm, P_DIRTY); 91 } 92 93 public String toString() 94 { 95 return "P_CLEAN"; 96 } 97 } 98 | Popular Tags |