/** * Constructor. * * @param pc the managed instance * @param sm the instance's state manager * @param load the set of detached field indexes * @param access whether to allow access to unloaded fields * @param multithreaded whether the instance will be used concurrently * by multiple threads */ public DetachedStateManager(PersistenceCapable pc, OpenJPAStateManager sm, BitSet load, boolean access, boolean multithreaded) { _pc = pc; _embedded = sm.isEmbedded(); _loaded = load; _access = access; _dirty = new BitSet(_loaded.length()); _oid = sm.fetchObjectId(); _version = sm.getVersion(); if (multithreaded) _lock = new ReentrantLock(); else _lock = null; }
/** * Create a new cacheable instance for the given state manager. */ private DataCachePCData newPCData(OpenJPAStateManager sm) { ClassMetaData meta = sm.getMetaData(); if (_gen != null) return (DataCachePCData) _gen.generatePCData (sm.getObjectId(), meta); return new DataCachePCDataImpl(sm.fetchObjectId(), meta); }
/** * Remove all values from the index that were for the given statemanager * * @param stateManager * @param queue */ public void removeIndexes(OpenJPAStateManager stateManager, IndexQueue queue, long clock) { ByteBuffer key = keyStrategy.toByteBuffer(stateManager.fetchObjectId()); DynamicComposite composite = newComposite(); composite.addComponent(key, buffSerializer); // queue the index values to be deleted queueDeletes(composite, queue, clock); }
/** * Delete the entity with the given statemanager. The given clock time is used * for the delete of indexes * * @param stateManager * @param mutator * @param clock */ @SuppressWarnings({ "unchecked", "rawtypes" }) public void delete(OpenJPAStateManager stateManager, Mutator mutator, long clock, IndexQueue queue) { ByteBuffer keyBytes = keyStrategy.toByteBuffer(stateManager.fetchObjectId()); // queue up direct column deletes for (AbstractCollectionField field : collectionFieldIds.values()) { field.removeCollection(stateManager, mutator, clock, keyBytes); } mutator.addDeletion(keyBytes, columnFamilyName, null, StringSerializer.get()); // queue all index removals for (AbstractIndexOperation current : indexOps.values()) { current.removeIndexes(stateManager, queue, clock); } }
/** * Create a new cacheable instance for the given state manager. */ private DataCachePCData newPCData(OpenJPAStateManager sm, DataCache cache) { ClassMetaData meta = sm.getMetaData(); if (_gen != null) return (DataCachePCData) _gen.generatePCData(sm.getObjectId(), meta); return new DataCachePCDataImpl(sm.fetchObjectId(), meta, cache.getName()); }
/** * Create a new cacheable instance for the given state manager. */ private DataCachePCData newPCData(OpenJPAStateManager sm, DataCache cache) { ClassMetaData meta = sm.getMetaData(); if (_gen != null) return (DataCachePCData) _gen.generatePCData(sm.getObjectId(), meta); return new DataCachePCDataImpl(sm.fetchObjectId(), meta, cache.getName()); }
/** * Create a new cacheable instance for the given state manager. */ private DataCachePCData newPCData(OpenJPAStateManager sm, DataCache cache) { ClassMetaData meta = sm.getMetaData(); if (_gen != null) return (DataCachePCData) _gen.generatePCData(sm.getObjectId(), meta); return new DataCachePCDataImpl(sm.fetchObjectId(), meta, cache.getName()); }
/** * Create a new cacheable instance for the given state manager. */ private DataCachePCData newPCData(OpenJPAStateManager sm, DataCache cache) { ClassMetaData meta = sm.getMetaData(); if (_gen != null) return (DataCachePCData) _gen.generatePCData(sm.getObjectId(), meta); return new DataCachePCDataImpl(sm.fetchObjectId(), meta, cache.getName()); }
/** * Get the stored entity and it's object id if it exists in the datastore * * @param stateManager * @param keyspace * @return */ public Class<?> getStoredEntityType(OpenJPAStateManager sm, Keyspace keyspace, MetaCache metaCache) { Object oid = sm.fetchObjectId(); Class<?> oidType = ((OpenJPAId) oid).getType(); // This entity has never been persisted, we can't possibly load it if (oidType == null) { return null; } ByteBuffer rowKey = keyStrategy.toByteBuffer(oid); if (rowKey == null) { return null; } String descrim = strategy.getStoredType(rowKey, columnFamilyName, keyspace); if (descrim == null) { return null; } return strategy.getClass(descrim, oidType, metaCache); }
else _dirty = new BitSet(_loaded.length()); _oid = sm.fetchObjectId(); _version = sm.getVersion(); if (multithreaded)
else _dirty = new BitSet(_loaded.length()); _oid = sm.fetchObjectId(); _version = sm.getVersion(); if (multithreaded)
else _dirty = new BitSet(_loaded.length()); _oid = sm.fetchObjectId(); _version = sm.getVersion(); if (multithreaded)
else _dirty = new BitSet(_loaded.length()); _oid = sm.fetchObjectId(); _version = sm.getVersion(); if (multithreaded)
/** * Find the persisted class in cassandra. If this is not a subclass, the oid * is always returned * * @param oid * @return */ public Class<?> getDataStoreId(OpenJPAStateManager sm, StoreContext ctx) { //If there's no id there's nothing to do, return null Class<?> requested = ((OpenJPAId) sm.fetchObjectId()).getType(); ClassMetaData metaData = ctx.getConfiguration() .getMetaDataRepositoryInstance() .getMetaData(requested, ctx.getClassLoader(), true); EntityFacade entityFacade = conf.getMetaCache().getFacade(metaData, conf.getSerializer()); if(entityFacade == null){ throw new MetaDataException(String.format("You attempted to load an object that has no mapping. Please check that class %s is mapped with a %s annotation, not a %s annoation", metaData.getDescribedType(), Entity.class.getName(), MappedSuperclass.class.getName())); } return entityFacade.getStoredEntityType(sm, conf.getKeyspace(), conf.getMetaCache()); }
DynamicComposite auditComposite, OpenJPAStateManager stateManager) { ByteBuffer key = keyStrategy.toByteBuffer(stateManager.fetchObjectId());
try { assertOpen(); Object oid = copy.fetchObjectId(); Class<?> type = copy.getManagedInstance().getClass(); if (oid == null)
try { assertOpen(); Object oid = copy.fetchObjectId(); Class<?> type = copy.getManagedInstance().getClass(); if (oid == null)
try { assertOpen(); Object oid = copy.fetchObjectId(); Class<?> type = copy.getManagedInstance().getClass(); if (oid == null)
try { assertOpen(); Object oid = copy.fetchObjectId(); Class<?> type = copy.getManagedInstance().getClass(); if (oid == null)
/** * If not already cached, create an empty copy of the given state * manager in the given state. */ OpenJPAStateManager copy(OpenJPAStateManager copy, PCState state) { beginOperation(true); try { assertOpen(); Object oid = copy.fetchObjectId(); Class type = copy.getManagedInstance().getClass(); if (oid == null) throw new InternalException(); // cached instance? StateManagerImpl sm = null; if (!copy.isEmbedded()) sm = getStateManagerImplById(oid, true); if (sm == null) { MetaDataRepository repos = _conf. getMetaDataRepositoryInstance(); ClassMetaData meta = repos.getMetaData(type, _loader, true); // construct a new state manager with all info known sm = new StateManagerImpl(oid, meta, this); sm.setObjectId(oid); sm.initialize(sm.getMetaData().getDescribedType(), state); } return sm; } finally { endOperation(); } }