1 10 11 package com.triactive.jdo.state; 12 13 import javax.jdo.JDOUserException; 14 import javax.jdo.Transaction; 15 16 17 class PersistentNewDeleted extends LifeCycleState 18 { 19 protected PersistentNewDeleted() 20 { 21 isPersistent = true; 22 isTransactional = true; 23 isDirty = true; 24 isNew = true; 25 isDeleted = true; 26 27 stateType = P_NEW_DELETED; 28 } 29 30 public LifeCycleState transitionMakeNontransactional(StateManagerImpl sm) 31 { 32 throw new JDOUserException("Cannot make object non-transactional: object is new, deleted and not yet committed", sm.getObject()); 33 } 34 35 public LifeCycleState transitionMakeTransient(StateManagerImpl sm) 36 { 37 throw new JDOUserException("Cannot make object transient: object is new, deleted, and not yet committed", sm.getObject()); 38 } 39 40 public LifeCycleState transitionCommit(StateManagerImpl sm, Transaction tx) 41 { 42 sm.clearPersistentFields(); 43 sm.evictFromTransaction(); 44 sm.disconnect(); 45 return changeState(sm, TRANSIENT); 46 } 47 48 public LifeCycleState transitionRollback(StateManagerImpl sm, Transaction tx) 49 { 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, Transaction tx) 59 { 60 throw new JDOUserException("Cannot read fields from a deleted object", sm.getObject()); 61 } 62 63 public LifeCycleState transitionWriteField(StateManagerImpl sm, Transaction tx) 64 { 65 throw new JDOUserException("Cannot write fields to a deleted object", sm.getObject()); 66 } 67 68 public String toString() 69 { 70 return "P_NEW_DELETED"; 71 } 72 } 73 | Popular Tags |