本文整理了Java中org.springframework.data.domain.Example.getProbeType()
方法的一些代码示例,展示了Example.getProbeType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Example.getProbeType()
方法的具体详情如下:
包路径:org.springframework.data.domain.Example
类名称:Example
方法名:getProbeType
[英]Get the actual type for the probe used. This is usually the given class, but the original class in case of a CGLIB-generated subclass.
[中]
代码示例来源:origin: spring-projects/spring-data-jpa
@Override
public <S extends T> List<S> findAll(Example<S> example, Sort sort) {
return getQuery(new ExampleSpecification<S>(example), example.getProbeType(), sort).getResultList();
}
代码示例来源:origin: spring-projects/spring-data-mongodb
/**
* Returns the given {@link Example} as {@link Document} holding matching values extracted from
* {@link Example#getProbe()}.
*
* @param example must not be {@literal null}.
* @return
*/
public Document getMappedExample(Example<?> example) {
Assert.notNull(example, "Example must not be null!");
return getMappedExample(example, mappingContext.getRequiredPersistentEntity(example.getProbeType()));
}
代码示例来源:origin: spring-projects/spring-data-jpa
@Override
public <S extends T> Optional<S> findOne(Example<S> example) {
try {
return Optional.of(
getQuery(new ExampleSpecification<S>(example), example.getProbeType(), Sort.unsorted()).getSingleResult());
} catch (NoResultException e) {
return Optional.empty();
}
}
代码示例来源:origin: spring-projects/spring-data-mongodb
private Set<Class<?>> getTypesToMatch(Example<?> example) {
Set<Class<?>> types = new HashSet<>();
for (TypeInformation<?> reference : mappingContext.getManagedTypes()) {
if (example.getProbeType().isAssignableFrom(reference.getType())) {
types.add(reference.getType());
}
}
return types;
}
代码示例来源:origin: spring-projects/spring-data-jpa
@Override
public <S extends T> boolean exists(Example<S> example) {
return !getQuery(new ExampleSpecification<S>(example), example.getProbeType(), Sort.unsorted()).getResultList()
.isEmpty();
}
代码示例来源:origin: spring-projects/spring-data-jpa
@Override
public <S extends T> List<S> findAll(Example<S> example) {
return getQuery(new ExampleSpecification<S>(example), example.getProbeType(), Sort.unsorted()).getResultList();
}
代码示例来源:origin: spring-projects/spring-data-jpa
@Override
public <S extends T> long count(Example<S> example) {
return executeCountQuery(getCountQuery(new ExampleSpecification<S>(example), example.getProbeType()));
}
代码示例来源:origin: spring-projects/spring-data-mongodb
@Override
public <S extends T> Optional<S> findOne(Example<S> example) {
Assert.notNull(example, "Sample must not be null!");
Query q = new Query(new Criteria().alike(example));
return Optional
.ofNullable(mongoOperations.findOne(q, example.getProbeType(), entityInformation.getCollectionName()));
}
代码示例来源:origin: spring-projects/spring-data-mongodb
@Override
public <S extends T> Mono<S> findOne(Example<S> example) {
Assert.notNull(example, "Sample must not be null!");
Query q = new Query(new Criteria().alike(example));
q.limit(2);
return mongoOperations.find(q, example.getProbeType(), entityInformation.getCollectionName()).buffer(2)
.map(vals -> {
if (vals.size() > 1) {
throw new IncorrectResultSizeDataAccessException(1);
}
return vals.iterator().next();
}).next();
}
代码示例来源:origin: spring-projects/spring-data-mongodb
@Override
public <S extends T> Page<S> findAll(final Example<S> example, Pageable pageable) {
Assert.notNull(example, "Sample must not be null!");
Assert.notNull(pageable, "Pageable must not be null!");
Query q = new Query(new Criteria().alike(example)).with(pageable);
List<S> list = mongoOperations.find(q, example.getProbeType(), entityInformation.getCollectionName());
return PageableExecutionUtils.getPage(list, pageable,
() -> mongoOperations.count(q, example.getProbeType(), entityInformation.getCollectionName()));
}
代码示例来源:origin: spring-projects/spring-data-mongodb
@Override
public <S extends T> List<S> findAll(Example<S> example, Sort sort) {
Assert.notNull(example, "Sample must not be null!");
Assert.notNull(sort, "Sort must not be null!");
Query q = new Query(new Criteria().alike(example)).with(sort);
return mongoOperations.find(q, example.getProbeType(), entityInformation.getCollectionName());
}
代码示例来源:origin: spring-projects/spring-data-mongodb
@Override
public <S extends T> Flux<S> findAll(Example<S> example, Sort sort) {
Assert.notNull(example, "Sample must not be null!");
Assert.notNull(sort, "Sort must not be null!");
Query query = new Query(new Criteria().alike(example)).with(sort);
return mongoOperations.find(query, example.getProbeType(), entityInformation.getCollectionName());
}
代码示例来源:origin: spring-projects/spring-data-mongodb
@Override
public <S extends T> long count(Example<S> example) {
Assert.notNull(example, "Sample must not be null!");
Query q = new Query(new Criteria().alike(example));
return mongoOperations.count(q, example.getProbeType(), entityInformation.getCollectionName());
}
代码示例来源:origin: spring-projects/spring-data-mongodb
@Override
public <S extends T> Mono<Boolean> exists(Example<S> example) {
Assert.notNull(example, "Sample must not be null!");
Query q = new Query(new Criteria().alike(example));
return mongoOperations.exists(q, example.getProbeType(), entityInformation.getCollectionName());
}
代码示例来源:origin: spring-projects/spring-data-jpa
@Override
public <S extends T> Page<S> findAll(Example<S> example, Pageable pageable) {
ExampleSpecification<S> spec = new ExampleSpecification<>(example);
Class<S> probeType = example.getProbeType();
TypedQuery<S> query = getQuery(new ExampleSpecification<>(example), probeType, pageable);
return isUnpaged(pageable) ? new PageImpl<>(query.getResultList()) : readPage(query, probeType, pageable, spec);
}
代码示例来源:origin: spring-projects/spring-data-mongodb
@Override
public <S extends T> boolean exists(Example<S> example) {
Assert.notNull(example, "Sample must not be null!");
Query q = new Query(new Criteria().alike(example));
return mongoOperations.exists(q, example.getProbeType(), entityInformation.getCollectionName());
}
代码示例来源:origin: spring-projects/spring-data-mongodb
@Override
public <S extends T> Mono<Long> count(Example<S> example) {
Assert.notNull(example, "Sample must not be null!");
Query q = new Query(new Criteria().alike(example));
return mongoOperations.count(q, example.getProbeType(), entityInformation.getCollectionName());
}
代码示例来源:origin: spring-projects/spring-data-jpa
/**
* Extract the {@link Predicate} representing the {@link Example}.
*
* @param root must not be {@literal null}.
* @param cb must not be {@literal null}.
* @param example must not be {@literal null}.
* @return never {@literal null}.
*/
public static <T> Predicate getPredicate(Root<T> root, CriteriaBuilder cb, Example<T> example) {
Assert.notNull(root, "Root must not be null!");
Assert.notNull(cb, "CriteriaBuilder must not be null!");
Assert.notNull(example, "Example must not be null!");
ExampleMatcher matcher = example.getMatcher();
List<Predicate> predicates = getPredicates("", cb, root, root.getModel(), example.getProbe(),
example.getProbeType(), new ExampleMatcherAccessor(matcher), new PathNode("root", null, example.getProbe()));
if (predicates.isEmpty()) {
return cb.isTrue(cb.literal(true));
}
if (predicates.size() == 1) {
return predicates.iterator().next();
}
Predicate[] array = predicates.toArray(new Predicate[0]);
return matcher.isAllMatching() ? cb.and(array) : cb.or(array);
}
代码示例来源:origin: spring-projects/spring-data-mongodb
/**
* Returns the given {@link Example} as {@link Document} holding matching values extracted from
* {@link Example#getProbe()}.
*
* @param example must not be {@literal null}.
* @param entity must not be {@literal null}.
* @return
*/
public Document getMappedExample(Example<?> example, MongoPersistentEntity<?> entity) {
Assert.notNull(example, "Example must not be null!");
Assert.notNull(entity, "MongoPersistentEntity must not be null!");
Document reference = (Document) converter.convertToMongoType(example.getProbe());
if (entity.getIdProperty() != null && ClassUtils.isAssignable(entity.getType(), example.getProbeType())) {
Object identifier = entity.getIdentifierAccessor(example.getProbe()).getIdentifier();
if (identifier == null) {
reference.remove(entity.getIdProperty().getFieldName());
}
}
ExampleMatcherAccessor matcherAccessor = new ExampleMatcherAccessor(example.getMatcher());
applyPropertySpecs("", reference, example.getProbeType(), matcherAccessor);
Document flattened = ObjectUtils.nullSafeEquals(NullHandler.INCLUDE, matcherAccessor.getNullHandler()) ? reference
: new Document(SerializationUtils.flattenMap(reference));
Document result = example.getMatcher().isAllMatching() ? flattened : orConcatenate(flattened);
return updateTypeRestrictions(result, example);
}
代码示例来源:origin: spring-projects/spring-data-redis
/**
* Retrieve a mapped {@link RedisOperationChain} to query secondary indexes given {@link Example}.
*
* @param example must not be {@literal null}.
* @return the mapped {@link RedisOperationChain}.
*/
public RedisOperationChain getMappedExample(Example<?> example) {
RedisOperationChain chain = new RedisOperationChain();
ExampleMatcherAccessor matcherAccessor = new ExampleMatcherAccessor(example.getMatcher());
applyPropertySpecs("", example.getProbe(), mappingContext.getRequiredPersistentEntity(example.getProbeType()),
matcherAccessor, example.getMatcher().getMatchMode(), chain);
return chain;
}
内容来源于网络,如有侵权,请联系作者删除!