@Override public long count() { return this.datastoreTemplate.count(this.entityType); }
@Override public void delete(T entity) { this.datastoreTemplate.delete(entity); }
@Override public void deleteAll() { this.datastoreTemplate.deleteAll(this.entityType); } }
@Override public Page<T> findAll(Pageable pageable) { Assert.notNull(pageable, "A non-null Pageable is required."); return new PageImpl<>( new ArrayList<>(this.datastoreTemplate .findAll(this.entityType, new DatastoreQueryOptions(pageable.getPageSize(), (int) pageable.getOffset(), pageable.getSort()))), pageable, this.datastoreTemplate.count(this.entityType)); }
@Override public Iterable<T> findAll() { return this.datastoreTemplate.findAll(this.entityType); }
@Override public <A> A performTransaction(Function<DatastoreRepository<T, ID>, A> operations) { return this.datastoreTemplate.performTransaction((template) -> operations .apply(new SimpleDatastoreRepository<>(template, this.entityType))); }
@Override public <S extends T> long count(Example<S> example) { Iterable<Key> keys = this.datastoreTemplate.keyQueryByExample(example, null); return StreamSupport.stream(keys.spliterator(), false).count(); }
@Override public Iterable<T> findAllById(Iterable<ID> ids) { return this.datastoreTemplate.findAllById(ids, this.entityType); }
@Override public Optional<T> findById(ID id) { return Optional.ofNullable(this.datastoreTemplate.findById(id, this.entityType)); }
@Override public boolean existsById(ID id) { return this.datastoreTemplate.existsById(id, this.entityType); }
@Override public void deleteById(ID id) { this.datastoreTemplate.deleteById(id, this.entityType); }
@Override public Page<T> findAll(Pageable pageable) { Assert.notNull(pageable, "A non-null Pageable is required."); return new PageImpl<>( new ArrayList<>(this.datastoreTemplate .findAll(this.entityType, new DatastoreQueryOptions(pageable.getPageSize(), (int) pageable.getOffset(), pageable.getSort()))), pageable, this.datastoreTemplate.count(this.entityType)); }
@Override public Iterable<T> findAll() { return this.datastoreTemplate.findAll(this.entityType); }
@Override public <A> A performTransaction(Function<DatastoreRepository<T, ID>, A> operations) { return this.datastoreTemplate.performTransaction((template) -> operations .apply(new SimpleDatastoreRepository<>(template, this.entityType))); }
@Override public <S extends T> boolean exists(Example<S> example) { Iterable<Key> keys = this.datastoreTemplate.keyQueryByExample(example, new DatastoreQueryOptions(1, null, null)); return StreamSupport.stream(keys.spliterator(), false).findAny().isPresent(); } }
@Override public Iterable<T> findAllById(Iterable<ID> ids) { return this.datastoreTemplate.findAllById(ids, this.entityType); }
@Override public Optional<T> findById(ID id) { return Optional.ofNullable(this.datastoreTemplate.findById(id, this.entityType)); }
@Override public boolean existsById(ID id) { return this.datastoreTemplate.existsById(id, this.entityType); }
@Override public void deleteById(ID id) { this.datastoreTemplate.deleteById(id, this.entityType); }
@Override public Iterable<T> findAll(Sort sort) { Assert.notNull(sort, "A non-null Sort is required."); return this.datastoreTemplate .findAll(this.entityType, new DatastoreQueryOptions(null, null, sort)); }