Package org.apache.openjpa.enhance

Examples of org.apache.openjpa.enhance.PersistenceCapable.pcGetStateManager()


    public Object getObjectId(Object obj) {
        assertOpen();
        if (ImplHelper.isManageable(obj)) {
            PersistenceCapable pc = ImplHelper.toPersistenceCapable(obj, _conf);
            if (pc != null) {
                if (pc.pcGetStateManager() == null) {
                    // If the statemanager is null the call to pcFetchObjectId always returns null. Create a new object
                    // id.
                    return ApplicationIds.create(pc, _repo.getMetaData(pc.getClass(), null, true));
                }
                return pc.pcFetchObjectId();
View Full Code Here


    public boolean isDetached(Object obj) {
        if (!(ImplHelper.isManageable(obj)))
            return false;

        PersistenceCapable pc = ImplHelper.toPersistenceCapable(obj, _conf);
        if (pc.pcGetStateManager() instanceof DetachedStateManager)
            return true;
        Boolean detached = pc.pcIsDetached();
        if (detached != null)
            return detached.booleanValue();
View Full Code Here

        boolean assertThisContext) {
        if (ImplHelper.isManageable(obj)) {
            PersistenceCapable pc = ImplHelper.toPersistenceCapable(obj, _conf);
            BrokerImpl pcBroker = (BrokerImpl)pc.pcGetGenericContext();
            if (pcBroker == this || isFromWriteBehindCallback())
                return (StateManagerImpl) pc.pcGetStateManager();
            if (assertThisContext && pcBroker != null)
                throw new UserException(_loc.get("not-managed",
                    Exceptions.toString(obj))).setFailedObject(obj);
        }
        return null;
View Full Code Here

                        itr.hasNext();) {
                        PersistenceCapable pc = (PersistenceCapable) itr.next();
                        if (pc == null) {
                            continue;
                        }
                        OpenJPAStateManager sm = (OpenJPAStateManager) pc.pcGetStateManager();
                        ClassMapping cm =
                            (ClassMapping) _conf.getMetaDataRepositoryInstance().getCachedMetaData(pc.getClass());
                        FieldMapping[] fmd = cm.getFieldMappings();
                        for (int j = 0; j < fmd.length; j++) {
                            // don't check the oids for basic fields.
View Full Code Here

     * Calculate proper attach strategy for instance.
     */
    private AttachStrategy getStrategy(Object toAttach) {
        PersistenceCapable pc = ImplHelper.toPersistenceCapable(toAttach,
            getBroker().getConfiguration());
        if (pc.pcGetStateManager() instanceof AttachStrategy)
            return (AttachStrategy) pc.pcGetStateManager();

        Object obj = pc.pcGetDetachedState();
        if (obj instanceof AttachStrategy)
            return (AttachStrategy) obj;
View Full Code Here

     */
    private AttachStrategy getStrategy(Object toAttach) {
        PersistenceCapable pc = ImplHelper.toPersistenceCapable(toAttach,
            getBroker().getConfiguration());
        if (pc.pcGetStateManager() instanceof AttachStrategy)
            return (AttachStrategy) pc.pcGetStateManager();

        Object obj = pc.pcGetDetachedState();
        if (obj instanceof AttachStrategy)
            return (AttachStrategy) obj;
        if (obj == null || obj == PersistenceCapable.DESERIALIZED) {
View Full Code Here

            manager.fireBeforeAttach(toAttach, meta);
        }

        // assign the detached pc the same state manager as the object we're
        // copying into during the attach process
        StateManager smBefore = pc.pcGetStateManager();
        pc.pcReplaceStateManager(sm);
        int detach = (isNew) ? DETACH_ALL : broker.getDetachState();
        FetchConfiguration fetch = broker.getFetchConfiguration();
        try {
            FieldMetaData[] fmds = sm.getMetaData().getFields();
View Full Code Here

                        itr.hasNext();) {
                        PersistenceCapable pc = (PersistenceCapable) itr.next();
                        if (pc == null) {
                            continue;
                        }
                        OpenJPAStateManager sm = (OpenJPAStateManager) pc.pcGetStateManager();
                        ClassMapping cm =
                            (ClassMapping) _conf.getMetaDataRepositoryInstance().getCachedMetaData(pc.getClass());
                        FieldMapping[] fmd = cm.getFieldMappings();
                        for (int j = 0; j < fmd.length; j++) {
                            // don't check the oids for basic fields.
View Full Code Here

                // get the StateManager of this toMany value
                // and find the value of the inverse mappedBy field (Customer)
                // for this toMacdny field
                PersistenceCapable pc = (PersistenceCapable)
                    ((Collection) coll).iterator().next();
                OpenJPAStateManager sm1 = (OpenJPAStateManager) pc.
                    pcGetStateManager();
               
                ClassMapping clm = ((ClassMapping) sm1.getMetaData());
                FieldMapping fm = (FieldMapping) clm.getField(
                    mappedByFieldMapping.getName());
View Full Code Here

            Object id = util.getIdentifier(instance);
            if (id != null)
                return id.toString();
            if (instance instanceof PersistenceCapable) {
                PersistenceCapable pc = (PersistenceCapable)instance;
                StateManager sm = pc.pcGetStateManager();
                id = sm == null ? null : sm.fetchObjectId();
            }
            return id == null ? "null" : id.toString();
        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.