Commit Graph

92 Commits

Author SHA1 Message Date
Simon Baslé
0095313342 DATACOUCH-199 - Make automatic index creation opt-in
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.
2016-02-05 18:08:05 +01:00
Simon Baslé
6d747e97f5 DATACOUCH-180 - Allow named parameters in inline N1QL queries
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.
2016-02-02 15:23:53 +01:00
Simon Baslé
8f5e9e3df8 DATACOUCH-187 - Allow counting queries and single projections.
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.
2016-01-27 12:23:16 +01:00
Simon Baslé
c589a13699 DATACOUCH-186 - Index-backed methods safe from deleted stales
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.
2016-01-18 18:24:50 +01:00
Simon Baslé
d81dc9aacc DATACOUCH-185 - view-based CRUD methods use default consistency
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.
2016-01-08 16:21:20 +01:00
Simon Baslé
aa3f9c380b DATACOUCH-176 - Geo false positive autoelimination
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.
2015-12-01 11:02:08 +01:00
Simon Baslé
2378e7145b DATACOUCH-166 - Improve SpEL support, prefix is now #{ 2015-11-16 14:15:50 +01:00
Simon Baslé
40d131aab0 DATACOUCH-169 - Automatic index creation
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.
2015-11-16 13:57:38 +01:00
Simon Baslé
ec129e86a8 DATACOUCH-166 - Add basic SpEL support
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.
2015-10-20 18:06:50 +02:00
Simon Baslé
c6aa84ced4 DATACOUCH-165 - Add utilities to remove geo false positives
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.
2015-10-14 16:49:51 +02:00
Simon Baslé
a2f26f4310 DATACOUCH-165 - Add geospatial support
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.
2015-10-14 15:26:22 +02:00
Simon Baslé
e4b103cdfa DATACOUCH-158 - Allow more explicit expiry unit
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.
2015-10-14 10:43:01 +02:00
Simon Baslé
7654af7608 DATACOUCH-164 - Use stable Couchbase SDK
Make modifications due to name changing in 2.2.0, the latest stable release of the Couchbase SDK.
2015-09-21 16:46:51 +02:00
Simon Baslé
f661bad73b Fix unit test compile error due to project layout
The integration part is not yet executed by automated test tools so the unit test couldn't find a Party class.
2015-09-21 15:41:15 +02:00
Simon Baslé
56ae8217e9 DATACOUCH-138 - Add Page/Slice/PagingAndSortingRepo
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.
2015-09-21 15:17:53 +02:00
Simon Baslé
f57a03ad21 DATACOUCH-156 - Make generated N1QL queries filter on the type field.
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.
2015-07-31 18:58:00 +02:00
Simon Baslé
f543e2b037 DATACOUCH-148 - Allow to configure repository queries consistency globally.
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.
2015-07-30 11:21:02 +02:00
Simon Baslé
508f190270 DATACOUCH-152 - Bump SDK to 2.2.0-dp2 and fix related TODOs.
ParametrizedQuery is now ParameterizedQuery, a few parameters have been added to the environment parsing, made use of N1QL Functions where newly available.
2015-07-27 13:22:05 +02:00
Simon Baslé
5114ddb867 DATACOUCH-145 - Use Id/Field annotations from Couchbase SDK
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.
2015-07-20 17:12:05 +02:00
Simon Baslé
712bc66006 DATACOUCH-144 - Detect N1QL dependency and fail fast if not available.
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.
2015-07-20 11:25:39 +02:00
Simon Baslé
4f0ba9d215 DATACOUCH-143 - Log executed queries in DEBUG. 2015-07-16 16:48:45 +02:00
Simon Baslé
c29727595c DATACOUCH-137 - queryDerivation for N1QL annotated methods.
Abstracted the N1QL-based variants in AbstractN1qlBasedQuery. This implementation doesn't recognize QueryParams or QueryPlan anymore in the method parameters so that the method signatures are not store-dependent.

Added query derivation from PartTree to N1QL query, using N1qlQueryCreator.

Unit tested the mapping between a Part.Type and the corresponding N1QL Expression.
2015-07-10 16:40:54 +02:00
Simon Baslé
9deaf6b480 DATACOUCH-136 - Add @N1QL query annotation.
The annotation allows to execute N1QL queries that are provided inline. For ease of use, one can use the placeholder $SELECT_ENTITY$ instead of writing the SELECT and FROM clauses.

QueryParams passed in as a method parameter will be used to enrich the Query. Other parameters on the annotated method will be used as values for positional placeholders in the statement.

The template's findByN1QL now expect enough data to reconstruct the full CouchbaseDocument (including ID and CAS), the ad hoc version of it has been renamed findByN1QLProjection.
2015-07-10 14:50:34 +02:00
Simon Baslé
b9f23f3fd5 DATACOUCH-135 - Migrate to Couchbase SDK 2.0 and add N1QL find method.
Adaptation were made to use SDK 2.0:
 - Reworked the configuration approach (more parts to be configured, like Environment, Cluster and Bucket)
 - Added a new xml schema for configuration of 2.0 version
 - Adapted the template
 - Added N1QL support in the template (findByN1QL)
 - Removed the cache package
 - Adapted the repository
 - Better separated Unit Tests from Integration Tests

All integration and unit tests pass, except one (SimpleCouchbaseRepositoryTests.shouldFindCustom).

Customisation of a ViewQuery will be addressed in another ticket.
2015-07-10 14:46:30 +02:00
Michael Nitschinger
4af3f32abb DATACOUCH-117 - Make sure fixture docs are persisted on tests. 2015-03-05 11:15:23 +01:00
Mark Paluch
2da3840334 DATACOUCH-109 - Provide CDI support for Spring Data Couchbase repositories
Initial integration to enable CDI usage of Spring Data Couchbase repositories
along with custom repository implementations.
2015-02-20 10:13:23 +01:00
Ståle Lyngaas
bfc4019eb1 DATACOUCH-110 - Tests from @winard pull request 2015-02-20 09:48:32 +01:00
kkrol89
ff15112959 DATACOUCH-25 - added support for TTL properties in Couchbase Cache Manager 2015-02-16 11:22:54 +01:00
Michael Nitschinger
264266c792 DATACOUCH-117 - Fix flaky tests when asserting json objects.
This changeset also increses the timeout for operations to 10 seconds
to reduce the possibility of false timeouts during test runs.
2015-01-20 10:47:16 +01:00
Michael Nitschinger
9f35068629 DATACOUCH-108 - Fix nondeterministic JSON response assertions. 2014-09-05 08:25:55 +02:00
Michael Nitschinger
b8866b3dac DATACOUCH-94: Move FieldNamingStrategy to commons. 2014-08-26 10:21:46 +02:00
Michael Nitschinger
a2cd30af3e DATACOUCH-86 - Implement Spring4 cache get with cast.
This changeset extends the CouchbaseCache to be compatible with the newly
added method of the Spring 4 cache interface.
2014-05-19 12:11:29 +02:00
Michael Nitschinger
e9ae5ba1c5 DATACOUCH-82 - Implement custom FieldNamingStrategies and abbreviation support. 2014-04-14 16:10:36 +02:00
Michael Nitschinger
b3a4069696 DATACOUCH-75 - Trim off find on custom repository finder. 2014-03-12 13:13:51 +01:00
Michael Nitschinger
de40287b75 DATACOUCH-71 Harden test case with relative checks. 2014-03-10 14:19:00 +01:00
Michael Nitschinger
ea6b14f4c9 DATACOUCH-71 - add execution listener to test 2014-03-10 14:08:49 +01:00
Michael Nitschinger
bef4d52ace DATACOUCH-71 - Add support for JSR 303 validation.
This changeset adds validation support for entities, and since this depends
on events, the event functionality has been added as well. Now also generic
event listeners can be attached.
2014-03-10 13:07:05 +01:00
Michael Nitschinger
62f974fa78 DATACOUCH-61 - Add Converter support for Jodatime
This changeset adds converters for Jodatime to unix timestamps and
back if jodatime is found on the classpath.
2014-03-10 10:49:07 +01:00
Michael Nitschinger
f68397f2ac DATACOUCH-69 - Support for Date and Calendar conversions.
This changeset adds aut of the box support for date and calendar objects.
They get converted to simple longs (unix timestamps) and back, since couchbase
server views have good support for those through the dateToArray() function.

A custom converter takes precedence though to customize these conversions.
2014-03-10 10:23:49 +01:00
Michael Nitschinger
332ce8c560 DATACOUCH-55 - Support custom converters.
This changeset adds the possibility to implement custom converters for entities and fields.
2014-03-10 09:22:31 +01:00
Michael Nitschinger
9c3cc52d2e DATACOUCH-47 - ensure multiple buckets are working over xml config.
This test verifies the functionality as reported in the ticket.
2014-01-24 12:41:38 +01:00
Michael Nitschinger
11ed095c58 DATACOUCH-65 - Add support for optimistic locking through @Version
@Version support is built on top of CAS values in couchbase. It does
not store an actual version number in the document, but rather reuses
cas values transparently to handle optimistic locking.

Also, write result checking has been added to the template for
better control what happens if a write fails. Defaults to NONE,
but can be sett to LOG or EXCEPTION.
2014-01-24 12:01:42 +01:00
Ken Dombeck
bb6385e08a DATACOUCH-57 - Allow for the configuration of CouchbaseClient to use properties
from property files or SPEL expressions.
2014-01-24 09:13:04 +01:00
Michael Nitschinger
7b6a3a9894 DATACOUCH-14 - Enable SLF4J as default logging.
If the whole system is constructed through the AbstractCouchbaseConfiguration or
the custom <couchbase> xml config, the logger is specified automatically.

Please note that this also changes the java config a little bit, but it should
also make it easier to construct it.
2014-01-23 16:24:58 +01:00
Michael Nitschinger
5414ee556b DATACOUCH-44 - Expose PersistTo/ReplicateTo on template
While users benefit from the exposure in terms of control, it is also
needed to make the unit tests more reliable as reported in the ticket.
2014-01-23 14:36:47 +01:00
Michael Nitschinger
9452c40eeb DATACOUCH-64 - Enable dynamic queries on repositories.
This changeset adds dynamic queries that can be annotated with @View and also provide a custom
Query param to change properties at runtime if needed.
2014-01-23 14:07:55 +01:00
Ken Dombeck
15ad87a82f DATACOUCH-58 allow for null values to be persisted for List elements and Map values. 2014-01-09 15:06:11 +01:00
Andrzej Wislowski
b11fc6c53c DATACOUCH-53 - protection against NPE on CouchbaseCache when putting null as a value 2014-01-09 14:41:11 +01:00
David Harrigan
7d79d79e28 DATACOUCH-30 - ObjectMapper configuration must be supported
Allow for a custom ObjectMapper to be used.
2014-01-09 14:32:18 +01:00
David Harrigan
1fc662b7cb DATACOUCH-35 - Can't deserialize Class fields.
Similar to Enums, Classes aren't a simple type, therefore have to handle using
the configured ObjectMapper.

-=david=-
2013-11-13 11:29:49 +01:00