/** * * @param oid * @return */ protected Class determineClassFromObjectId(Object oid) { if (oid instanceof OpenJPAId) { return ((OpenJPAId) oid).getType(); } return null; } }
public void newPut(Object oid) { if (!enabled) { return; } if (oid instanceof OpenJPAId) { newPut(((OpenJPAId) oid).getType()); } }
public void newPut(Object oid) { if (!enabled) { return; } if (oid instanceof OpenJPAId) { newPut(((OpenJPAId) oid).getType()); } }
public void newPut(Object oid) { if (!enabled) { return; } if (oid instanceof OpenJPAId) { newPut(((OpenJPAId) oid).getType()); } }
public void newGet(Object oid, boolean hit) { if (!enabled) { return; } if (oid instanceof OpenJPAId) { newGet(((OpenJPAId) oid).getType(), hit); } }
public void newGet(Object oid, boolean hit) { if (!enabled) { return; } if (oid instanceof OpenJPAId) { newGet(((OpenJPAId) oid).getType(), hit); } }
public void newGet(Object oid, boolean hit) { if (!enabled) { return; } if (oid instanceof OpenJPAId) { newGet(((OpenJPAId) oid).getType(), hit); } }
public void newGet(Object oid, boolean hit) { if (!enabled) { return; } if (oid instanceof OpenJPAId) { newGet(((OpenJPAId) oid).getType(), hit); } }
public void newPut(Object oid) { if (!enabled) { return; } if (oid instanceof OpenJPAId) { newPut(((OpenJPAId) oid).getType()); } }
private void delete(OpenJPAId oid, CompassSession session) { Class cls = oid.getType(); Object id = oid.getIdObject(); session.delete(cls, id); }
/** * * @param oid * @return */ @Override protected DataCachePCData getInternal(Object oid) { Element result = null; if (oid instanceof OpenJPAId) { Class cls = ((OpenJPAId) oid).getType(); Ehcache cache = findCache(cls); if (cache == null) { return null; } else { result = cache.get(oid); } } else { for (Ehcache cache : caches.values()) { result = cache.get(oid); if (result != null) { break; } } } if (result == null) { return null; } else { return (DataCachePCData) result.getObjectValue(); } }
@SuppressWarnings({"unchecked"}) private void reindexOid(OpenJPAId oid, OpenJPAEntityManager em, CompassSession session) { try { Object o = em.find(oid.getType(), oid.getIdObject()); reindex(o, session); } catch (EntityNotFoundException e) { delete(oid, session); } }
@Override public boolean initialize(OpenJPAStateManager stateManager, PCState pcState, FetchConfiguration fetchConfiguration, Object obj) { // if it's an abstract type, we couldn't find it in the datastore // because getManagedType returned null // and the framework set the class type to the type the user queried. // Just return false because it doesn't exist Class<?> type = cassandraStore.getDataStoreId(stateManager, this.getContext()); if(type == null){ return false; } Class<?> requestedType = ((OpenJPAId)stateManager.getId()).getType(); /** * Requested class is a superclass of the stored type. */ if(!requestedType.isAssignableFrom(type)){ return false; } log.debug("In initialize operation..."); stateManager.initialize(type, pcState); stateManager.load(fetchConfiguration); return true; }
Class<?> cls = ((OpenJPAId) oid).getType(); return getMetaData(cls, envLoader, mustExist);
Class<?> cls = ((OpenJPAId) oid).getType(); return getMetaData(cls, envLoader, mustExist);
/** * 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); }
/** * 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()); }
/** * Overrides to target specific slices for find() calls. */ @Override public Object processArgument(Object oid) { TargetFetchConfiguration fetch = getFetchConfiguration(); if (!fetch.isExplicitTarget()) { FinderTargetPolicy policy = _conf.getFinderTargetPolicyInstance(); if (policy != null) { if (oid instanceof OpenJPAId) { String[] targets = policy.getTargets(((OpenJPAId) oid).getType(), ((OpenJPAId) oid).getIdObject(), _conf.getActiveSliceNames(), this); fetch.setTargets(targets); } } } return super.processArgument(oid); } }
/** * Overrides to target specific slices for find() calls. */ @Override public Object processArgument(Object oid) { TargetFetchConfiguration fetch = getFetchConfiguration(); if (!fetch.isExplicitTarget()) { FinderTargetPolicy policy = _conf.getFinderTargetPolicyInstance(); if (policy != null) { if (oid instanceof OpenJPAId) { String[] targets = policy.getTargets(((OpenJPAId) oid).getType(), ((OpenJPAId) oid).getIdObject(), _conf.getActiveSliceNames(), this); fetch.setTargets(targets); } } } return super.processArgument(oid); } }
/** * Overrides to target specific slices for find() calls. */ @Override public Object processArgument(Object oid) { TargetFetchConfiguration fetch = getFetchConfiguration(); if (!fetch.isExplicitTarget()) { FinderTargetPolicy policy = _conf.getFinderTargetPolicyInstance(); if (policy != null) { if (oid instanceof OpenJPAId) { String[] targets = policy.getTargets(((OpenJPAId) oid).getType(), ((OpenJPAId) oid).getIdObject(), _conf.getActiveSliceNames(), this); fetch.setTargets(targets); } } } return super.processArgument(oid); } }