TransientDirty.java :  » Database-ORM » TJDO » com » triactive » jdo » state » Java Open Source

Java Open Source » Database ORM » TJDO 
TJDO » com » triactive » jdo » state » TransientDirty.java
/*
 * 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: TransientDirty.java,v 1.1 2004/01/18 03:01:06 jackknifebarber Exp $
 */

package com.triactive.jdo.state;

import javax.jdo.JDOUserException;
import javax.jdo.Transaction;


class TransientDirty extends LifeCycleState
{
    protected TransientDirty()
    {
        isPersistent = false;
        isTransactional = true;
        isDirty = true;
        isNew = false;
        isDeleted = false;

        stateType = T_DIRTY;
    }

    public LifeCycleState transitionMakePersistent(StateManagerImpl sm, Transaction tx)
    {
        return changeState(sm, P_NEW);
    }

    public LifeCycleState transitionDeletePersistent(StateManagerImpl sm, Transaction tx)
    {
        throw new JDOUserException("Cannot delete, object is not persistent", sm.getObject());
    }

    public LifeCycleState transitionMakeNontransactional(StateManagerImpl sm)
    {
        throw new JDOUserException("Cannot make object non-transactional: object is dirty", sm.getObject());
    }

    public LifeCycleState transitionCommit(StateManagerImpl sm, Transaction tx)
    {
        sm.discardSavedFields();
        sm.evictFromTransaction();
        return changeState(sm, T_CLEAN);
    }

    public LifeCycleState transitionRollback(StateManagerImpl sm, Transaction tx)
    {
        sm.restoreFields();
        sm.replaceSCOFields();
        sm.evictFromTransaction();
        return changeState(sm, T_CLEAN);
    }

    public String toString()
    {
        return "T_DIRTY";
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.