1 10 11 package com.triactive.jdo.state; 12 13 import com.triactive.jdo.TransactionNotActiveException; 14 import javax.jdo.JDOUserException; 15 import javax.jdo.Transaction; 16 17 18 class TransientClean extends LifeCycleState 19 { 20 protected TransientClean() 21 { 22 28 isPersistent = false; 29 isTransactional = true; 30 isDirty = false; 31 isNew = false; 32 isDeleted = false; 33 34 stateType = T_CLEAN; 35 } 36 37 public LifeCycleState transitionMakePersistent(StateManagerImpl sm, Transaction tx) 38 { 39 if (!tx.isActive()) 40 throw new TransactionNotActiveException(); 41 42 sm.saveFields(); 43 sm.enlistInTransaction(); 44 return changeState(sm, P_NEW); 45 } 46 47 public LifeCycleState transitionDeletePersistent(StateManagerImpl sm, Transaction tx) 48 { 49 throw new JDOUserException("Cannot delete, object is not persistent", sm.getObject()); 50 } 51 52 public LifeCycleState transitionMakeNontransactional(StateManagerImpl sm) 53 { 54 sm.disconnect(); 55 return changeState(sm, TRANSIENT); 56 } 57 58 public LifeCycleState transitionWriteField(StateManagerImpl sm, Transaction tx) 59 { 60 if (tx.isActive()) 61 { 62 sm.saveFields(); 63 sm.enlistInTransaction(); 64 return changeState(sm, T_DIRTY); 65 } 66 else 67 return this; 68 } 69 70 public String toString() 71 { 72 return "T_CLEAN"; 73 } 74 } 75 | Popular Tags |