Package org.datanucleus.state

Examples of org.datanucleus.state.StateManager


            if (getApiAdapter().isPersistent(obj))
            {
                assertActiveTransaction();
            }
            StateManager sm = findStateManager(obj);
            if (sm == null)
            {
                sm = (StateManager) ObjectProviderFactory.newForTransactionalTransient(this, obj);
            }
            sm.makeTransactional();
        }
        finally
        {
            clr.unsetPrimary();
        }
View Full Code Here


            if (!getApiAdapter().isPersistent(obj) && getApiAdapter().isTransactional(obj) && getApiAdapter().isDirty(obj))
            {
                throw new NucleusUserException(LOCALISER.msg("010024"));
            }

            StateManager sm = findStateManager(obj);
            sm.makeNontransactional();
        }
        finally
        {
            clr.unsetPrimary();
        }
View Full Code Here

        if (api.isDetached(pc))
        {
            // Detached, so migrate to attached
            if (cache != null)
            {
                StateManager l1CachedSM = (StateManager)cache.get(id);
                if (l1CachedSM != null && l1CachedSM.getObject() != pc)
                {
                    // attached object with the same id already present in the L1 cache so cannot attach in-situ
                    throw new NucleusUserException(LOCALISER.msg("010017",
                        StringUtils.toJVMIDString(pc)));
                }
            }

            if (NucleusLogger.PERSISTENCE.isDebugEnabled())
            {
                NucleusLogger.PERSISTENCE.debug(LOCALISER.msg("010016", StringUtils.toJVMIDString(pc)));
            }
            StateManager sm =
                (StateManager) ObjectProviderFactory.newForDetached(this, pc, id, api.getVersionForObject(pc));
            sm.attach(sco);
        }
        else
        {
            // Not detached so can't attach it. Just return
            return;
View Full Code Here

        Object pcTarget = null;
        if (sco)
        {
            // SCO PC (embedded/serialised)
            boolean detached = getApiAdapter().isDetached(pc);
            StateManager smTarget = (StateManager) ObjectProviderFactory.newForEmbedded(this, pc, true, null, -1);
            pcTarget = smTarget.getObject();
            if (detached)
            {
                // If the object is detached, re-attach it
                if (NucleusLogger.PERSISTENCE.isDebugEnabled())
                {
                    NucleusLogger.PERSISTENCE.debug(LOCALISER.msg("010018",
                        StringUtils.toJVMIDString(pc), StringUtils.toJVMIDString(pcTarget)));
                }

                smTarget.attachCopy(pc, sco);
            }
        }
        else
        {
            // FCO PC
View Full Code Here

            {
                persistObjectInternal(obj, null, null, -1, ObjectProvider.PC);
            }
        }

        StateManager sm = findStateManager(obj);
        if (sm == null)
        {
            throw new NucleusUserException(LOCALISER.msg("010007", getApiAdapter().getIdForObject(obj)));
        }
        sm.detach(state);
    }
View Full Code Here

            {
                // Passing in a detached (dirty or clean) instance, so get a persistent copy to detach
                thePC = findObject(getApiAdapter().getIdForObject(thePC), false, true, null);
            }

            StateManager sm = findStateManager(thePC);
            if (sm == null)
            {
                throw new NucleusUserException(LOCALISER.msg("010007", getApiAdapter().getIdForObject(thePC)));
            }

            return sm.detachCopy(state);
        }
        finally
        {
            clr.unsetPrimary();
        }
View Full Code Here

        Set objs = new HashSet();
        Collection sms = enlistedSMCache.values();
        Iterator<StateManager> smsIter = sms.iterator();
        while (smsIter.hasNext())
        {
            StateManager sm = smsIter.next();
            objs.add(sm.getObject());
        }
        return objs;
    }
View Full Code Here

        Set objs = new HashSet();
        Collection sms = enlistedSMCache.values();
        Iterator<StateManager> smsIter = sms.iterator();
        while (smsIter.hasNext())
        {
            StateManager sm = smsIter.next();
            for (int i=0;i<classes.length;i++)
            {
                if (classes[i] == sm.getObject().getClass())
                {
                    objs.add(sm.getObject());
                    break;
                }
            }
        }
        return objs;
View Full Code Here

        Set objs = new HashSet();
        Collection sms = enlistedSMCache.values();
        Iterator<StateManager> smsIter = sms.iterator();
        while (smsIter.hasNext())
        {
            StateManager sm = smsIter.next();
            for (int i=0;i<states.length;i++)
            {
                if (getApiAdapter().getObjectState(sm.getObject()).equals(states[i]))
                {
                    objs.add(sm.getObject());
                    break;
                }
            }
        }
        return objs;
View Full Code Here

        Collection sms = enlistedSMCache.values();
        Iterator<StateManager> smsIter = sms.iterator();
        while (smsIter.hasNext())
        {
            boolean matches = false;
            StateManager sm = smsIter.next();
            for (int i=0;i<states.length;i++)
            {
                if (getApiAdapter().getObjectState(sm.getObject()).equals(states[i]))
                {
                    for (int j=0;i<classes.length;i++)
                    {
                        if (classes[j] == sm.getObject().getClass())
                        {
                            matches = true;
                            objs.add(sm.getObject());
                            break;
                        }
                    }
                }
                if (matches)
View Full Code Here

TOP

Related Classes of org.datanucleus.state.StateManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.