1 10 11 package com.triactive.jdo.state; 12 13 import javax.jdo.JDOUserException; 14 import javax.jdo.Transaction; 15 16 17 class PersistentNew extends LifeCycleState 18 { 19 protected PersistentNew() 20 { 21 isPersistent = true; 22 isTransactional = true; 23 isDirty = true; 24 isNew = true; 25 isDeleted = false; 26 27 stateType = P_NEW; 28 } 29 30 public LifeCycleState transitionDeletePersistent(StateManagerImpl sm, Transaction tx) 31 { 32 sm.preDelete(); 33 return changeState(sm, P_NEW_DELETED); 34 } 35 36 public LifeCycleState transitionMakeNontransactional(StateManagerImpl sm) 37 { 38 throw new JDOUserException("Cannot make object non-transactional: object is new and not yet committed", sm.getObject()); 39 } 40 41 public LifeCycleState transitionMakeTransient(StateManagerImpl sm) 42 { 43 throw new JDOUserException("Cannot make object transient: object is new and not yet committed", sm.getObject()); 44 } 45 46 public LifeCycleState transitionCommit(StateManagerImpl sm, Transaction tx) 47 { 48 sm.discardSavedFields(); 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 sm.restoreFields(); 67 68 sm.evictFromTransaction(); 69 sm.disconnect(); 70 return changeState(sm, TRANSIENT); 71 } 72 73 public String toString() 74 { 75 return "P_NEW"; 76 } 77 } 78 | Popular Tags |