Use the reworked version of the EntityCallback method lookup.
Also fix issues with callbacks not invoked when intended and rework the reactive flow by removing deeply nested constructs.
Update documentation and add EntityCallbacks to BulkOperations.
Original Pull Request: #742
We now use EntityCallback to invoke callback actions on entities before saving/before conversion to provide hooks that potentially modify an entity before persisting it.
We also provide a reactive variant of entity callbacks allowing to consume Reactor Context and to defer the actual activity.
Original Pull Request: #742
Current MongoAnnotationProcessor still uses 3.x.x Querydsl package names.
Update package names to com.querydsl.core.annotations.* to use Querydsl annotations for code-generation.
Original pull request: #755.
We now support hashed index definitions via IndexOperations. Reading index information back allows to identify a hashed index via isHashed().
Original pull request: #750.
OutOperation now supports the expanded format for the $out aggregation operation if additional parameters, next to the target collection, are given.
Aggregation.out("out-col").insertDocuments().in("database-2").uniqueKey("field-1“);
{
$out : {
to : "out-col",
mode : "insertDocuments",
db : "database-2",
uniqueKey : "field-1"
}
}
We’ll stick to the 2.6 format if only a collection name has been set.
Aggregation.out("out-col“);
{ $out : "out-col" }
Original pull request: #740.
We now make sure to call the delegate AggregationOperationContext without potentially overriding arguments. Without this change potentially registered target types would be overridden with null.
We now apply propagate the cursor size to aggregation options. We introduced AggregationOptions.comment to propagate the meta comment to aggregation execution.
Original pull request: #743.
Use MongoQueryMethod.getDomainClass() instead of getRepositoryDomainType(). Simplify annotation presence indicator methods hasAnnotatedSort() and hasAnnotatedCollation(). Refactor getAnnotatedAggregation() to non-nullable method throwing IllegalStateException to be consistent with other getXxx() methods.
Simplify aggregation execution and consider collection/single element declaration for reactive execution.
Tweak docs.
Original pull request: #743.
Reuse collection name for index creation instead of resolving the collection for every index. Switch lambda to method reference.
Original pull request: #746.
We now lazily read the collection of an entity as it potentially requires a more expensive SpEL evaluation that might not have been required in fist place.
Original pull request: #746.
Fix count operation inside transaction and avoid superfluous client session instantiation.
Default MongoDatabase emission in case of non active transaction, update documentation, move test to another package.
Delay reactive collection re/creation in test to cope with issues in server version 4.1.10.
Original Pull Request: #745
Support declarative reactive transaction via the Transactional annotation via a MongoDB specific ReactiveTransactionManager implementation.
@Bean
ReactiveMongoTransactionManager transactionManager(ReactiveDatabaseFactory factory) {
return new ReactiveMongoTransactionManager(factory);
}
@Component
public class StateService {
@Transactional
Mono<UpdateResult> someBusinessFunction(Step step) {
return template.insert(step)
.then(process(step))
.then(template.update(Step.class).apply(Update.set("state", …));
};
});
Original Pull Request: #745
Store result to getPersistentEntity() in local variable to reduce invocation count. Use numbered postfix instead of object instantiation to generate a unique distance field name.
Deprecate geoNear methods with hint to aggregations. Fix distance field usage in ReactiveMongoTemplate.
Tweak docs.
Original pull request: #744.
Deprecate and guard tests for removed commands:
- eval
- group
- maxScan
- geoNear
Transition from removed geoNear command to $geoNear aggregation pipeline stage.
This allows users to still use NearQuery along with the template that now transforms the query into a GeoNearOperation applying skip (previously in memory skipping) and limit (previous num parameter) as additional aggregation pipeline stages.
Tested against:
- 4.1.10
- 4.0.4
- 3.6.12
- 4.4.20
Original pull request: #744.
The collation can now also be configured on entity level and gets applied via MongoTemplate. However one can alway override a default collation by adding the collation explicitly to either the Query or one of the Options available for various operations.
When it comes to the repository level the hierarchy is method parameter over query annotation over entity metadata.
Remove collation annotation in favor of attributes of Query / Document.
Original pull request: #644.
We now allow to specify the collation via the @Query annotation.
public interface PersonRepository extends MongoRepository<Person, String> {
@Query(collation = "en_US")
List<Person> findByFirstname(String firstname);
@Query(collation = "{ 'locale' : 'en_US' }")
List<Person> findPersonByFirstname(String firstname);
@Query(collation = "?1")
List<Person> findByFirstname(String firstname, Object collation);
@Query(collation = "{ 'locale' : '?1' }")
List<Person> findByFirstname(String firstname, String collation);
List<Person> findByFirstname(String firstname, Collation collation);
}
We now make sure to include collation information derived from the Query method if the collation is a fixed value.
Original pull request: #644.