In addition to annotating the repository with xxxIndexed annotations, user must now opt-in to the feature by redefining the indexManager bean in the configuration. This is so production use of this feature is actively discouraged.
Choice of placeholder "mode" is determined by the syntax used inside the query, early during repository instantiation.
An IllegalArgumentException is thrown if both named and positional parameters are used.
The generated view's default map function now emits meta.id so that CRUD findAll(ids) works.
The default value for the view name is now "all".
The ViewIndexed isn't documented as applicable to METHODs (deferred feature).
This change allows simple projections to types long, boolean, String when an inline N1QL query uses an aggregation function like AVG, COUNT.
The projection's result must be a single row with a single key/value pair in the N1QL response. Only the value gets returned.
Added an integration test for custom method customization.
Moved the integration test for base class customization.
Put the samples in the documentation in a new "Changing Repository Behaviour" section.
This commit ensures that methods in the template and the repository base classes are correctly ignoring documents that have been deleted but are still identified by the view due to using weak consistency (Stale.TRUE).
FindByView in template now ignores null rows in its result list. It also correctly forces the includeDocs parameter in order not to risk a bad transcoding of the document (javadoc clarified).
DeleteAll in the repository CRUD implementation will correctly detect attempts at deleting a non-existing document (DocumentDoesNotExistException is also correctly mapped to a Spring Data exception now).
DeleteAll behavior with DataRetrievalFailureException is tested in RepositoryIndexUsageTest.
The CRUD methods that are backed by a view in SimpleCouchbaseRepository now take the default view consistency into account.
This includes findAll(), findAll(keys), count() and deleteAll().
PagingAndSortingRepository findAll methods already took the default N1QL consistency into account.
This is verified in an unit test and has been made more explicit in the repository documentation.
This fixes the fact that EnableCouchbaseRepository(repositoryBaseClass = Something.class) was ignored.
Now using reflection to choose the target implementation. Note that custom base classes MUST extend SimpleCouchbaseRepository (or its subclass N1qlCouchbaseRepository).
An example in the form of an integration test has been added in src/integration/java/org/springframework/data/couchbase/repository/base/RepositoryBaseTest.java.
So far with geo queries a bounding box approximation was performed on Circle and Polygon queries (since Couchbase internally only supports Bounding Box queries).
It was confusing since in previous iteration it was up to the user to remove these false positives "after the fact" in code calling the repository.
This change allows for the framework to retain enough information to perform false positives elimination automatically and transparently for the user.
The configuration step made it look like a new mapping was necessary in overrides, whereas it is actually possible and clearer to mutate the base mapping.
Added a convenience method to get the MappingContext from the repository mapping.
Main indexes (ie indexes that can be used by repositories to retrieve ALL the documents of a particular entity type) are covered.
Repository interfaces can be annotated with an annotation for each type of main index that can be automatically created.
The IndexManager is responsible for creating said indexes (potentially skipping creation if an index is already in place, or if the IndexManager has been configured to skip it, see constructor).
Since IndexManager is created as a bean (either in JavaConfig or xml), there can be a different instance eg. in Prod vs Dev.
Added doc and integration test.
Renamed package core.view to core.query since it now contains various non-view related annotations and classes.
Detection whether or not reduce should be activated is now centralized. Triggers are:
- using the count prefix instead of find in method name
- setting reduce = true in the View annotation explicitly.
The reduce can thus be returning any kind of value (added an integration example with _stats), which is now properly documented.
Added the step of parsing SpEL expressions delimited by ${ } in StringN1qlBasedQuery, then the actual evaluation of each expression.
Refactored StringN1qlBasedQuery to use SpEL across the board, including for N1QL specific placeholders (SELECT-FROM, WHERE filter, etc...).
Refactored StringN1qlBasedQuery to use local methods rather than static methods, and amended the unit tests accordingly (using mocks).
Refactored getStatement and getCountStatement so they can see the parameters passed in at runtime.
Added unit tests + integration test.
Added SpEL support example in documentation.
In some places in the doc (javadoc, README, asciidoc), the annotation was still referred to as N1QL instead of Query...
Improved doc on inline statement for N1QL queries allowing the use of positional `$1` placeholders.
PointInShapeEvaluator can be used to check answers and remove false positives from answers that have been approximated (circle and polygon).
One implementations are provided, based on awt.
Hinted at the existence of the PointInShapeEvaluator in the message that warns about bounding box approximations.
Added mention of the AwtPointInShapeEvaluator in the asciidoc with code sample.
Add support for geo queries through the use of Spatial Views. This needs the query method to be annotated with @Dimensional (or a meta-annotation of it that is runtime retained).
See SpatialViewQueryCreator javadoc for supported part types and corresponding expected arguments (to be documented).
In a nutshell WITHIN Box (other shapes supported but approximated to bounding box), NEAR Point+Distance (approximated to bounding box), plus a few simple operators for dimensions beyond 2.
When approximating, a DEBUG log is made along the logging of the query.
Conversion methods from Shapes to bounding boxes are done in a GeoUtils class.
Unit and Integration test of the feature.
Added documentation for @Dimensional query derivation.
Added a configuration bean that allows to express what CouchbaseOperations each repository should use, individually or by domain type.
Added documentation for the feature in repository section.
The Document annotation now also support explicitly giving a TimeUnit for the expiry, ensuring the framework will correctly convert that to the expected Couchbase format.
Add support for Page / Slice in N1QL query derived methods.
Add PagingAndSortingRepository support through a N1qlCouchbaseRepository implementation. It will only be used as a base if N1QL is actually available on the cluster.
Refactor out some steps of entity related query creation in a N1qlUtils class, so that they can be also done eg. in repository base classes.
Add tests for both N1qlUtils and the N1qlCouchbaseRepository.
Document that PagingAndSortingRepository is supported provided N1QL is available on the Couchbase cluster.
The generated N1QL queries currently don't filter on the type at all.
Add a criteria to the WHERE clause that checks the field holding type information is matching the entity fully qualified class name.
Add a placeholder for inline N1QL queries that can be replaced by the same type information criteria.
Additionally to resolving a POJO attribute to JSON field name, the path conversion step will also escape each part of the doted path, in order to avoid problems with N1QL keywords.
In the SimpleCouchbaseRepository the guessed design document was lowercase of the entity class, whereas in ViewBasedCouchbaseQuery it is uncapitalized (only first letter is lowercase).
This has been made consistent, using the uncapitalize method. The doc now reflects that and explicitly have examples with camel case classes (UserInfo instead of User).
The consistency to apply on generated view queries (Stale) and N1QL queries (ScanConsistency) can now be chosen via the configuration, through a more abstract Consistency enumeration.
It is accessed from the CouchbaseOperations interface but is used in the repository only. In xml, the consistency attribute is on the couchbase:template element (string value of the enum to be passed in).
Documentation has been amended to describe this feature.
ParametrizedQuery is now ParameterizedQuery, a few parameters have been added to the environment parsing, made use of N1QL Functions where newly available.
Replaces all references to BeanWrapper with usage of PersistentPropertyAccessor API. MappingCouchbaseEntityInformation now extends PersistentEntityInformation to get rid of obsolete code implemented by the superclass.
The @Field annotation has been removed in favor of the one from the Couchbase SDK.
Similarly, CouchbasePersistentEntity now recognize the SDK's @Id annotation. Note that if both Spring Data and Couchbase @Id are present (on two distinct fields), the one from Spring Data will be taken into account.
Detect N1QL is not available at configuration time for the repositories and at runtime for the template. This throws a UnsupportedCouchbaseFeatureException.
The ClusterInfo is captured at bootstrap and used to determine if the feature is available. The xml configuration will need the ClusterInfo-related credentials to be provided explicitly.
The documentation has been updated to reflect the changes in the new Spring Data Couchbase 2.0.
A simple list of major changes to take into account when migrating from 1.x to 2.x has been added.
README.md has also been updated.