Examples of OpenJPAStateManager


Examples of org.apache.openjpa.kernel.OpenJPAStateManager

        else
            row.setObject(col, val);
    }

    public Boolean isCustomInsert(OpenJPAStateManager sm, JDBCStore store) {
        OpenJPAStateManager em = sm.getContext().getStateManager(sm.fetchObject
            (field.getIndex()));
        Boolean custom = isCustom(INSERT, sm, em, store);
        if (Boolean.TRUE.equals(custom) && _synthetic)
            return null;
        return custom;
View Full Code Here

Examples of org.apache.openjpa.kernel.OpenJPAStateManager

            return null;
        return custom;
    }

    public Boolean isCustomUpdate(OpenJPAStateManager sm, JDBCStore store) {
        OpenJPAStateManager em = sm.getContext().getStateManager(sm.fetchObject
            (field.getIndex()));
        Boolean custom = isCustom(UPDATE, sm, em, store);
        if (Boolean.TRUE.equals(custom) && _synthetic)
            return null;
        return custom;
View Full Code Here

Examples of org.apache.openjpa.kernel.OpenJPAStateManager

            return null;
        return custom;
    }

    public Boolean isCustomDelete(OpenJPAStateManager sm, JDBCStore store) {
        OpenJPAStateManager em = sm.getContext().getStateManager(sm.fetchObject
            (field.getIndex()));
        return isCustom(DELETE, sm, em, store);
    }
View Full Code Here

Examples of org.apache.openjpa.kernel.OpenJPAStateManager

        return (hasCustom) ? Boolean.TRUE : Boolean.FALSE;
    }

    public void customInsert(OpenJPAStateManager sm, JDBCStore store)
        throws SQLException {
        OpenJPAStateManager em = store.getContext().getStateManager
            (sm.fetchObject(field.getIndex()));
        if (em == null)
            em = new NullEmbeddedStateManager(sm, field);
        FieldMapping[] fields = field.getEmbeddedMapping().getFieldMappings();
        for (int i = 0; i < fields.length; i++)
View Full Code Here

Examples of org.apache.openjpa.kernel.OpenJPAStateManager

                fields[i].customInsert(em, store);
    }

    public void customUpdate(OpenJPAStateManager sm, JDBCStore store)
        throws SQLException {
        OpenJPAStateManager em = store.getContext().getStateManager
            (sm.fetchObject(field.getIndex()));
        if (em == null)
            em = new NullEmbeddedStateManager(sm, field);
        FieldMapping[] fields = field.getEmbeddedMapping().getFieldMappings();
        for (int i = 0; i < fields.length; i++)
            if (em.getDirty().get(i)
                && !em.getFlushed().get(i)
                && !Boolean.FALSE.equals(fields[i].isCustomUpdate(em, store)))
                fields[i].customUpdate(em, store);
    }
View Full Code Here

Examples of org.apache.openjpa.kernel.OpenJPAStateManager

                fields[i].customUpdate(em, store);
    }

    public void customDelete(OpenJPAStateManager sm, JDBCStore store)
        throws SQLException {
        OpenJPAStateManager em = store.getContext().getStateManager
            (sm.fetchObject(field.getIndex()));
        if (em == null)
            em = new NullEmbeddedStateManager(sm, field);
        FieldMapping[] fields = field.getEmbeddedMapping().getFieldMappings();
        for (int i = 0; i < fields.length; i++)
View Full Code Here

Examples of org.apache.openjpa.kernel.OpenJPAStateManager

        //### call will always return false, meaning we always have to assume
        //### we selected the embedded object fields and load the object
        //### immediately; this will be inefficient when the embedded object
        //### was not selected after all
        StoreContext ctx = store.getContext();
        OpenJPAStateManager em = ctx.embed(null, null, sm, field);
        sm.storeObject(field.getIndex(), em.getManagedInstance());
        boolean needsLoad = loadFields(em, store, fetch, res);

        // After loading everything from result, load the rest of the
        // configured fields if anything is missing.
        if (needsLoad &&
            fetch.requiresFetch(field.getFieldMetaData()) ==
                JDBCFetchConfiguration.FETCH_LOAD) {
          em.load(fetch);
        }
    }
View Full Code Here

Examples of org.apache.openjpa.kernel.OpenJPAStateManager

            }

            // update pcdatas for updates
            if (_updates != null) {
                BitSet fields;
                OpenJPAStateManager sm;
                for (Map.Entry<OpenJPAStateManager, BitSet> entry : _updates.entrySet()) {
                    sm = entry.getKey();
                    fields = entry.getValue();

                    cache = _mgr.selectCache(sm);
                    if (cache == null) {
                        continue;
                    }

                    // it's ok not to clone the object that we get from the cache,
                    // since we're inside the commit() method, so any modifications
                    // to the underlying cache are valid. If the commit had not
                    // already succeeded, then we'd want to clone the retrieved
                    // object.
                    data = cache.get(sm.getObjectId());
                    mods = getModifications(modMap, cache);

                    // data should always be non-null, since the object is
                    // dirty, but maybe it got dropped from the cache in the
                    // interim
                    if (data == null) {
                        data = newPCData(sm, cache);
                        data.store(sm);
                        mods.newUpdates.add(new PCDataHolder(data, sm));
                    } else {
                        data.store(sm, fields);
                        mods.existingUpdates.add(new PCDataHolder(data, sm));
                    }
                    CacheStatistics stats = cache.getStatistics();
                    if (stats.isEnabled()) {
                        ((CacheStatisticsSPI)stats).newPut(data.getType());
                    }
                }
            }

            // remove pcdatas for deletes
            if (_deletes != null) {
                for (OpenJPAStateManager sm : _deletes) {
                    cache = _mgr.selectCache(sm);
                    if (cache == null)
                        continue;

                    mods = getModifications(modMap, cache);
                    mods.deletes.add(sm.getObjectId());
                }
            }

            // notify the caches of the changes
            if (modMap != null) {
View Full Code Here

Examples of org.apache.openjpa.kernel.OpenJPAStateManager

        // for each loaded instance, merge loaded state into cached data

        boolean isNew;

        for(Map.Entry<OpenJPAStateManager, BitSet> entry : unloaded.entrySet()) {
            OpenJPAStateManager sm = entry.getKey();
            fields = entry.getValue();

            cache = _mgr.selectCache(sm);
            if (cache == null || sm.isEmbedded() || (failed != null
                && failed.contains(sm.getId())))
                continue;

            // make sure that we're not trying to cache an old version
            cache.writeLock();
            try {
                data = cache.get(sm.getObjectId());
                if (data != null && compareVersion(sm, sm.getVersion(),
                    data.getVersion()) == VERSION_EARLIER)
                    continue;

                isNew = data == null;
                if (isNew)
View Full Code Here

Examples of org.apache.openjpa.kernel.OpenJPAStateManager

     * somewhat tolerant of such behavior, in that the cache will be cleaned
     * up as failures occur.
     */
    private void notifyOptimisticLockFailure(OptimisticException e) {
        Object o = e.getFailedObject();
        OpenJPAStateManager sm = _ctx.getStateManager(o);
        if (sm == null)
            return;
        Object oid = sm.getId();
        boolean remove;

        // this logic could be more efficient -- we could aggregate
        // all the cache->oid changes, and then use DataCache.removeAll()
        // and less write locks to do the mutation.
        DataCache cache = _mgr.selectCache(sm);
        if (cache == null)
            return;

        cache.writeLock();
        try {
            DataCachePCData data = cache.get(oid);
            if (data == null)
                return;

            switch (compareVersion(sm, sm.getVersion(), data.getVersion())) {
                case StoreManager.VERSION_LATER:
                case StoreManager.VERSION_SAME:
                    // This tx's current version is later than or the same as
                    // the data cache version. In this case, the commit should
                    // have succeeded from the standpoint of the cache. Remove
                    // the instance from cache in the hopes that the cache is
                    // out of sync.
                    remove = true;
                    break;
                case StoreManager.VERSION_EARLIER:
                    // This tx's current version is earlier than the data
                    // cache version. This is a normal optimistic lock failure.
                    // Do not clean up the cache; it probably already has the
                    // right values, and if not, it'll get cleaned up by a tx
                    // that fails in one of the other case statements.
                    remove = false;
                    break;
                case StoreManager.VERSION_DIFFERENT:
                    // The version strategy for the failed object does not
                    // store enough information to optimize for expected
                    // failures. Clean up the cache.
                    remove = true;
                    break;
                default:
                    // Unexpected return value. Remove to be future-proof.
                    remove = true;
                    break;
            }
            if (remove)
                // remove directly instead of via the RemoteCommitListener
                // since we have a write lock here already, so this is more
                // efficient than read-locking and then write-locking later.
                cache.remove(sm.getId());
        } finally {
            cache.writeUnlock();
        }

        // fire off a remote commit stalenesss detection event.
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.