@Override public <T> T update(Object id, T objectToUpdate) { return super.update(id, objectToUpdate); }
@Override public RedisMappingContext getMappingContext() { return (RedisMappingContext) super.getMappingContext(); }
@Override public void destroy(KeyValueOperations instance, CreationalContext<KeyValueOperations> creationalContext) { if (instance.getMappingContext() instanceof DisposableBean) { try { ((DisposableBean) instance.getMappingContext()).destroy(); instance.destroy(); } catch (Exception e) { throw new IllegalStateException(e); } } super.destroy(instance, creationalContext); }
@Override public <T> T insert(T objectToInsert) { KeyValuePersistentEntity<?, ?> entity = getKeyValuePersistentEntity(objectToInsert); GeneratingIdAccessor generatingIdAccessor = new GeneratingIdAccessor(entity.getPropertyAccessor(objectToInsert), entity.getIdProperty(), identifierGenerator); Object id = generatingIdAccessor.getOrGenerateIdentifier(); return insert(id, objectToInsert); }
@Override public long count(KeyValueQuery<?> query, Class<?> type) { return executeRequired(adapter -> adapter.count(query, resolveKeySpace(type))); }
@Override public long count(@Nullable SpelCriteria criteria, String keyspace) { return filterMatchingRange(IterableConverter.toList(getRequiredAdapter().getAllOf(keyspace)), criteria, -1, -1) .size(); }
/** * Creates a new {@link SpelQueryEngine}. */ public SpelQueryEngine() { super(new SpelCriteriaAccessor(PARSER), new SpelSortAccessor(PARSER)); }
@Override @SuppressWarnings("unchecked") public <T, ID> EntityInformation<T, ID> getEntityInformation(Class<T> domainClass) { RedisPersistentEntity<T> entity = (RedisPersistentEntity<T>) operations.getMappingContext() .getRequiredPersistentEntity(domainClass); return new MappingRedisEntityInformation<>(entity); } }
@Override public <T> T insert(Object id, T objectToInsert) { if (objectToInsert instanceof PartialUpdate) { doPartialUpdate((PartialUpdate<?>) objectToInsert); return objectToInsert; } if (!(objectToInsert instanceof RedisData)) { RedisConverter converter = adapter.getConverter(); RedisPersistentEntity<?> entity = converter.getMappingContext() .getRequiredPersistentEntity(objectToInsert.getClass()); KeyValuePersistentProperty idProperty = entity.getRequiredIdProperty(); PersistentPropertyAccessor<T> propertyAccessor = entity.getPropertyAccessor(objectToInsert); if (propertyAccessor.getProperty(idProperty) == null) { propertyAccessor.setProperty(idProperty, id); return super.insert(id, propertyAccessor.getBean()); } } return super.insert(id, objectToInsert); }
/** * Creates new {@link AbstractKeyValueAdapter} with using the default query engine. * * @param engine will be defaulted to {@link SpelQueryEngine} if {@literal null}. */ protected AbstractKeyValueAdapter(@Nullable QueryEngine<? extends KeyValueAdapter, ?, ?> engine) { this.engine = engine != null ? engine : new SpelQueryEngine(); this.engine.registerAdapter(this); }
@Override public long count(KeyValueQuery<?> query, String keyspace) { return engine.count(query, keyspace); } }
@Override public Collection<?> find(KeyValueQuery<?> query, Serializable keyspace) { // TODO Auto-generated method stub return super.find(query, keyspace); }
@Override public long count(KeyValueQuery<?> query, Class<?> type) { return executeRequired(adapter -> adapter.count(query, resolveKeySpace(type))); }
/** * Creates a new {@link SpelQueryEngine}. */ public SpelQueryEngine() { super(new SpelCriteriaAccessor(PARSER), new SpelSortAccessor(PARSER)); }
@Override protected RepositoryFragments getRepositoryFragments(RepositoryMetadata metadata) { RepositoryFragments fragments = RepositoryFragments.empty(); if (QueryByExampleExecutor.class.isAssignableFrom(metadata.getRepositoryInterface())) { RedisMappingContext mappingContext = (RedisMappingContext) this.operations.getMappingContext(); RedisPersistentEntity<?> persistentEntity = mappingContext.getRequiredPersistentEntity(metadata.getDomainType()); MappingRedisEntityInformation<?, ?> entityInformation = new MappingRedisEntityInformation<>(persistentEntity); fragments = fragments.append(RepositoryFragment.implemented(QueryByExampleExecutor.class, getTargetRepositoryViaReflection(QueryByExampleRedisExecutor.class, entityInformation, operations))); } return fragments; }
@Override public <T> T update(T objectToUpdate) { if (objectToUpdate instanceof PartialUpdate) { doPartialUpdate((PartialUpdate<?>) objectToUpdate); return objectToUpdate; } return super.update(objectToUpdate); }
@Override public RedisMappingContext getMappingContext() { return (RedisMappingContext) super.getMappingContext(); }
@Override public long count(KeyValueQuery<?> query, Class<?> type) { return executeRequired(adapter -> adapter.count(query, resolveKeySpace(type))); }
/** * Creates a new {@link SpelQueryEngine}. */ public SpelQueryEngine() { super(new SpelCriteriaAccessor(PARSER), new SpelSortAccessor(PARSER)); }