/*
* Copyright 2004 (C) TJDO.
* All rights reserved.
*
* This software is distributed under the terms of the TJDO License version 1.0.
* See the terms of the TJDO License in the documentation provided with this software.
*
* $Id: PersistentDeleted.java,v 1.6 2004/01/18 03:01:06 jackknifebarber Exp $
*/
package com.triactive.jdo.state;
import javax.jdo.JDOUserException;
import javax.jdo.Transaction;
class PersistentDeleted extends LifeCycleState
{
protected PersistentDeleted()
{
isPersistent = true;
isTransactional = true;
isDirty = true;
isNew = false;
isDeleted = true;
stateType = P_DELETED;
}
public LifeCycleState transitionMakeNontransactional(StateManagerImpl sm)
{
throw new JDOUserException("Cannot make object non-transactional: object has been deleted", sm.getObject());
}
public LifeCycleState transitionMakeTransient(StateManagerImpl sm)
{
throw new JDOUserException("Cannot make object transient: object has been deleted", sm.getObject());
}
public LifeCycleState transitionCommit(StateManagerImpl sm, Transaction tx)
{
sm.clearPersistentFields();
sm.evictFromTransaction();
sm.disconnect();
return changeState(sm, TRANSIENT);
}
public LifeCycleState transitionRollback(StateManagerImpl sm, Transaction tx)
{
if (tx.getRestoreValues())
{
sm.restoreFields();
sm.replaceSCOFields();
sm.evictFromTransaction();
return changeState(sm, P_NONTRANS);
}
else
{
sm.clearPersistentFields();
sm.discardSavedFields();
sm.evictFromTransaction();
return changeState(sm, HOLLOW);
}
}
public LifeCycleState transitionReadField(StateManagerImpl sm, Transaction tx)
{
throw new JDOUserException("Cannot read fields from a deleted object", sm.getObject());
}
public LifeCycleState transitionWriteField(StateManagerImpl sm, Transaction tx)
{
throw new JDOUserException("Cannot write fields to a deleted object", sm.getObject());
}
public String toString()
{
return "P_DELETED";
}
}
|