-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FMWK-261 Align find APIs to use Query instead of Qualifier #652
Conversation
…ate AerospikeCriteria, Qualifier implements CriteriaDefinition
# Conflicts: # src/main/java/org/springframework/data/aerospike/query/KeyQualifier.java # src/main/java/org/springframework/data/aerospike/repository/support/SimpleAerospikeRepository.java # src/test/java/org/springframework/data/aerospike/repository/PersonRepositoryQueryTests.java
@agrgr What about Operations/Template (for both reactive and non-reactive) changes? we need to replace all We shouldn't have any find..Qualifier (ById, Using, findAll...) exposed in our interfaces/implementations after migrating to Query. |
Right, there was findByQualifier() in reactive flow which is now updated. |
We still have bunch of Let's talk about it tomorrow. |
Ok, firstly I thought this PR would handle just replacing findByQualifier. Went back to your description, makes sense. Will add an update aligning methods. |
* @return Stream of entities. | ||
*/ | ||
<T, S> Stream<?> findUsingQualifier(Class<T> entityClass, Class<S> targetClass, @Nullable Filter filter, | ||
Qualifier qualifier); | ||
<T, S> Stream<?> find(Query query, Class<T> entityClass, Class<S> targetClass, @Nullable Filter filter); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return Stream<S>
* @param filter Secondary index filter. | ||
* @return Stream of entities. | ||
*/ | ||
<T, S> Flux<?> find(Query query, Class<T> entityClass, Class<S> targetClass, @Nullable Filter filter); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return Flux<S>
if (criteria == null) { | ||
return null; | ||
} else if (criteria.getQualifiers() == null) { | ||
return new Qualifier[]{(criteria)}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(criteria) -> criteria
@@ -712,11 +712,11 @@ public interface AerospikeOperations { | |||
* @param id The id of the document to find. Must not be {@literal null}. | |||
* @param entityClass The class to extract the Aerospike set from. Must not be {@literal null}. | |||
* @param targetClass The class to map the document to. | |||
* @param qualifiers {@link Qualifier}s provided to build a filter Expression for the query. Optional argument. | |||
* @param query {@link Query} provided to build a filter expression. Optional argument. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...to build a filter expression
is not accurate, filters could also lead to statement filters and Query might also contain sorting and limiting options (same for other query param descriptions in javadocs)
* @return Stream of entities. | ||
*/ | ||
<T> Stream<T> findUsingQualifier(Class<T> entityClass, @Nullable Filter filter, Qualifier qualifier); | ||
<T> Stream<T> find(Query query, Class<T> entityClass, @Nullable Filter filter); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need the filter? filtering (both statement and expressions) comes from the Qualifier within the Query, consult with @reugn wether we should still expose Filter as a param.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, having the Query parameter only should be enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. For future: there in an opportunity to add a condition in StatementBuilder to check Filter first and not build Qualifier-constructed Filter if it already exists
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this might be a breaking change if we had Filter exposed in Template/Operations/Repository, talked with @agrgr and agreed to verify that, if its a breaking change it might be the first one for this release (which may require major version release).
try { | ||
AerospikePersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(entityClass); | ||
Key key = getKey(id, setName); | ||
|
||
if (targetClass != null && targetClass != entityClass) { | ||
return getRecordMapToTargetClass(entity, key, targetClass, qualifiers); | ||
return getRecordMapToTargetClass(entity, key, targetClass, criteria); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only used in one place and we are passing criteria now so no need for this method to accept Qualifier... (varargs) but a single Qualifier object, try to see how deep it goes, wherever you can - use Qualifier instead of Qualifier... (varargs).
List<Object> ids; | ||
if (criteria.hasSingleId()) { | ||
ids = getIdValue(criteria); | ||
return operations.findByIdsUsingQuery(ids, entityClass, targetClass, (Query) null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant (Query) casting
@@ -62,8 +60,8 @@ protected Query prepareQuery(Object[] parameters, ParametersParameterAccessor ac | |||
PartTree tree = new PartTree(queryMethod.getName(), entityClass); | |||
Query baseQuery = createQuery(accessor, tree); | |||
|
|||
AerospikeCriteria criteria = baseQuery.getAerospikeCriteria(); | |||
Query query = new Query(criteria); | |||
Qualifier qualifiers = baseQuery.getCriteria().getCriteriaObject(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
qualifier
instead of qualifiers
* Find all entities that have primary key in the given list. | ||
* | ||
* @param ids List of primary keys | ||
*/ | ||
List<P> findById(List<String> ids); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why findById
and not findByIds
if it gets a list of ids? same for many methods in this class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it is in repository, so it needs the exact name of the field
findUsingQuery() instead of findByQualifier(), deprecate AerospikeCriteria, Qualifier implements CriteriaDefinition