Package org.apache.openjpa.enhance

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


    protected StateManagerImpl getStateManagerImpl(Object obj,
        boolean assertThisContext) {
        if (ImplHelper.isManageable(obj)) {
            PersistenceCapable pc = ImplHelper.toPersistenceCapable(obj, _conf);
            if (pc.pcGetGenericContext() == this)
                return (StateManagerImpl) pc.pcGetStateManager();
            if (assertThisContext && pc.pcGetGenericContext() != null)
                throw new UserException(_loc.get("not-managed",
                    Exceptions.toString(obj))).setFailedObject(obj);
        }
        return null;
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

        // from other persistence contexts, so try to get sm directly from
        // instance before asking our context
        if (ImplHelper.isManageable(val)) {
            PersistenceCapable pc = ImplHelper.toPersistenceCapable(val,
                store.getConfiguration());
            if (pc.pcGetStateManager() != null)
                return pc.pcGetStateManager();
        }
        return RelationStrategies.getStateManager(val, store.getContext());
    }
View Full Code Here

        // instance before asking our context
        if (ImplHelper.isManageable(val)) {
            PersistenceCapable pc = ImplHelper.toPersistenceCapable(val,
                store.getConfiguration());
            if (pc.pcGetStateManager() != null)
                return pc.pcGetStateManager();
        }
        return RelationStrategies.getStateManager(val, store.getContext());
    }

    public Object toObjectValue(ValueMapping vm, Object val,
View Full Code Here

        // instance before asking our context
        OpenJPAStateManager sm;
        if (ImplHelper.isManageable(obj)) {
          PersistenceCapable pc = ImplHelper.toPersistenceCapable(obj,
                    getRepository().getConfiguration());
            sm = (OpenJPAStateManager) pc.pcGetStateManager();
            if (sm == null) {
              ret = getValueFromUnmanagedInstance(obj, cols, true);
            } else if (sm.isDetached()) {
              obj = store.getContext().find(sm.getObjectId(), false, null);
              sm = store.getContext().getStateManager(obj);
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 = meta.getFields();
View Full Code Here

    if (obj == null)
      return null;
    PersistenceCapable pc = ImplHelper.toPersistenceCapable(obj, null);
    if (pc == null)
      return null;
    StateManagerImpl sm = (StateManagerImpl)pc.pcGetStateManager();
    if (sm == null)
      return null;
    Object slice = sm.getImplData();
    return (slice instanceof String) ? (String)slice : null;
  }
View Full Code Here

        // instance before asking our context
        OpenJPAStateManager sm;
        if (ImplHelper.isManageable(obj)) {
          PersistenceCapable pc = ImplHelper.toPersistenceCapable(obj,
                    getRepository().getConfiguration());
            sm = (OpenJPAStateManager) pc.pcGetStateManager();
            if (sm == null) {
              ret = getValueFromUnmanagedInstance(obj, cols, true);
            } else if (sm.isDetached()) {
              obj = store.getContext().find(sm.getObjectId(), false, null);
              sm = store.getContext().getStateManager(obj);
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.