DATAKV-95 - Added exists(…) method to QuerydslKeyValueRepository.
Renamed QueryDsl… classes to Querydsl… for consistency. Restructured test cases for repositories to make better use of generics.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
* Copyright 2014-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -32,12 +32,15 @@ import com.mysema.query.types.Path;
|
||||
import com.mysema.query.types.path.PathBuilder;
|
||||
|
||||
/**
|
||||
* Utilities for Querydsl usage.
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @author Thomas Darimont
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
abstract class KeyValueQueryDslUtils {
|
||||
abstract class KeyValueQuerydslUtils {
|
||||
|
||||
private KeyValueQueryDslUtils() {
|
||||
private KeyValueQuerydslUtils() {
|
||||
// prevent instantiation
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
* Copyright 2014-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -45,6 +45,7 @@ import org.springframework.util.ClassUtils;
|
||||
* {@link org.springframework.data.keyvalue.repository.KeyValueRepository}.
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public class KeyValueRepositoryFactory extends RepositoryFactorySupport {
|
||||
|
||||
@@ -106,7 +107,7 @@ public class KeyValueRepositoryFactory extends RepositoryFactorySupport {
|
||||
EntityInformation<?, Serializable> entityInformation = getEntityInformation(metadata.getDomainType());
|
||||
|
||||
if (ClassUtils.isAssignable(QueryDslPredicateExecutor.class, metadata.getRepositoryInterface())) {
|
||||
return new QueryDslKeyValueRepository(entityInformation, keyValueOperations);
|
||||
return new QuerydslKeyValueRepository(entityInformation, keyValueOperations);
|
||||
}
|
||||
|
||||
return new SimpleKeyValueRepository(entityInformation, keyValueOperations);
|
||||
@@ -118,7 +119,7 @@ public class KeyValueRepositoryFactory extends RepositoryFactorySupport {
|
||||
*/
|
||||
@Override
|
||||
protected Class<?> getRepositoryBaseClass(RepositoryMetadata metadata) {
|
||||
return isQueryDslRepository(metadata.getRepositoryInterface()) ? QueryDslKeyValueRepository.class
|
||||
return isQueryDslRepository(metadata.getRepositoryInterface()) ? QuerydslKeyValueRepository.class
|
||||
: SimpleKeyValueRepository.class;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
* Copyright 2014-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.keyvalue.repository.support;
|
||||
|
||||
import static org.springframework.data.keyvalue.repository.support.KeyValueQueryDslUtils.*;
|
||||
import static org.springframework.data.keyvalue.repository.support.KeyValueQuerydslUtils.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -42,10 +42,11 @@ import com.mysema.query.types.path.PathBuilder;
|
||||
* {@link KeyValueRepository} implementation capable of executing {@link Predicate}s using {@link CollQuery}.
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @param <T>
|
||||
* @param <ID>
|
||||
* @author Oliver Gierke
|
||||
* @param <T> the domain type to manage
|
||||
* @param <ID> the identififer type of the domain type
|
||||
*/
|
||||
public class QueryDslKeyValueRepository<T, ID extends Serializable> extends SimpleKeyValueRepository<T, ID> implements
|
||||
public class QuerydslKeyValueRepository<T, ID extends Serializable> extends SimpleKeyValueRepository<T, ID> implements
|
||||
QueryDslPredicateExecutor<T> {
|
||||
|
||||
private static final EntityPathResolver DEFAULT_ENTITY_PATH_RESOLVER = SimpleEntityPathResolver.INSTANCE;
|
||||
@@ -54,25 +55,25 @@ public class QueryDslKeyValueRepository<T, ID extends Serializable> extends Simp
|
||||
private final PathBuilder<T> builder;
|
||||
|
||||
/**
|
||||
* Creates a new {@link QueryDslKeyValueRepository} for the given {@link EntityInformation} and
|
||||
* Creates a new {@link QuerydslKeyValueRepository} for the given {@link EntityInformation} and
|
||||
* {@link KeyValueOperations}.
|
||||
*
|
||||
* @param entityInformation must not be {@literal null}.
|
||||
* @param operations must not be {@literal null}.
|
||||
*/
|
||||
public QueryDslKeyValueRepository(EntityInformation<T, ID> entityInformation, KeyValueOperations operations) {
|
||||
public QuerydslKeyValueRepository(EntityInformation<T, ID> entityInformation, KeyValueOperations operations) {
|
||||
this(entityInformation, operations, DEFAULT_ENTITY_PATH_RESOLVER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link QueryDslKeyValueRepository} for the given {@link EntityInformation},
|
||||
* Creates a new {@link QuerydslKeyValueRepository} for the given {@link EntityInformation},
|
||||
* {@link KeyValueOperations} and {@link EntityPathResolver}.
|
||||
*
|
||||
* @param entityInformation must not be {@literal null}.
|
||||
* @param operations must not be {@literal null}.
|
||||
* @param resolver must not be {@literal null}.
|
||||
*/
|
||||
public QueryDslKeyValueRepository(EntityInformation<T, ID> entityInformation, KeyValueOperations operations,
|
||||
public QuerydslKeyValueRepository(EntityInformation<T, ID> entityInformation, KeyValueOperations operations,
|
||||
EntityPathResolver resolver) {
|
||||
|
||||
super(entityInformation, operations);
|
||||
@@ -162,6 +163,15 @@ public class QueryDslKeyValueRepository<T, ID extends Serializable> extends Simp
|
||||
return prepareQuery(predicate).count();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.querydsl.QueryDslPredicateExecutor#exists(com.mysema.query.types.Predicate)
|
||||
*/
|
||||
@Override
|
||||
public boolean exists(Predicate predicate) {
|
||||
return prepareQuery(predicate).exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates executable query for given {@link Predicate}.
|
||||
*
|
||||
Reference in New Issue
Block a user