Commit Graph

152 Commits

Author SHA1 Message Date
mikereiche
05fb9eadbe DATACOUCH-585 - Support ScanConsistency for count() queries. 2020-07-17 11:53:45 -07:00
mikereiche
e2444403a7 DATACOUCH-580 - Do not automatically insert n1ql.filter predicate in string query.
Since it is difficult to determine where the n1ql.filter (which typically
filters on _class), and also because it is not mandator, including
the n1ql.filter in the @query is left up to the author of the query.
Example:
@query("#{#n1ql.selectEntity} where #{#n1ql.filter} and lastname = $1")
2020-07-15 11:13:50 -07:00
mikereiche
d2456bb166 DATACOUCH-533 - Promote id field if no annotation id.
Promote id field if no annotation id.
Note that there is no longer any Couchbase @Id annotation - only
the Spring @id annotation.
2020-07-02 10:36:31 -07:00
mikereiche
ecaf58db75 DATACOUCH-532 - Use parameters in queries instead of literals.
This will allow query plans to be reused for different parameters.
2020-06-25 19:30:21 -07:00
mikereiche
5cd916bea4 DATACOUCH-577 - Fix tests that run only when using UNMANAGED couchbase server.
Some of the tests that run as UNMANAGED and pass when ran from intellij were
failing when ran from the command-line mvn, or when ran together will other tests.
2020-06-25 13:18:17 -07:00
mikereiche
c7f41f57ed DATACOUCH-574 - Support countBy...() query method calls in repository. 2020-06-24 16:00:26 -07:00
mikereiche
cd595995ed DATACOUCH-573 - use same name for count in query 2020-06-23 12:40:01 -07:00
mikereiche
54d1a45b35 DATACOUCH-572 - fix compile error from DATACOUCH-571 2020-06-23 09:44:42 -07:00
mikereiche
fc67a7b541 DATACOUCH-569 - Add tests for DATACOUCH-560 - serialization of nested objects (CouchbaseDocument) and lists (CouchbaseList) 2020-06-22 11:07:47 -07:00
mikereiche
e1d39fdb6f DATACOUCH-571 fix delimiters in generated id
Also clean up test domain/Config.java
2020-06-22 11:01:17 -07:00
mikereiche
69f1ff5791 DATACOUCH-546 - set generated id on entity returned to caller 2020-06-19 14:56:37 -07:00
mikereiche
041b987eaf DATACOUCH-484 - thread safety parameters test 2020-06-16 13:37:22 -07:00
mikereiche
610c02c66e DATACOUCH-484 - test to demonstrate that parameters are thread-safe 2020-06-15 13:00:25 -07:00
Andrea Torlaschi
c7f12a2237 DATACOUCH-560 - Serialization of CouchbaseDocument and CouchbaseList.
Add support for saving document with lists and composed objects.
Convert CouchbaseDocument/CouchbaseList to Map/List before saving.
2020-06-10 12:27:15 -07:00
mikereiche
fbf9b3eb29 DATACOUCH-545 - return null if not found instead of throwing an exception 2020-06-09 15:43:33 -07:00
mikereiche
95c69ea8cc DATACOUCH-525 - support custom type field name and custome type field value
MOTIVATION
customers would like to specify a type field other than _class, and
would like to specify a type field value other than the class name
of the domain object

CHANGES
Follow the instructions at
https://stackoverflow.com/questions/38847605/how-to-use-spring-data-with-couchbase-without-class-attribute
in the test domain, supply a CustomMappingCouchbaseConvert class that leverates a
TypeBasedCouchbaseTypeMapper, which in turn uses a TypeAwareTypeInformationMapper.
The typeKey used is "t". The TypeAwareTypeInformationMapper uses the DocumentType annotation
as the value for the type map entry. The domain Person object has @DocumentType("p"), which
will result in type mapping of "t" : "p" for Person objects.

In addition, when a query is composed, the typeKey and typeValue are taken from the converter.
2020-06-05 10:43:39 -07:00
mikereiche
dafff211a4 DATACOUCH-542 - support @Field to supply a different name for a field 2020-06-04 09:00:42 -07:00
mikereiche
0c8c8245fb DATACOUCH-561 - Better Testing for String Query 2020-05-28 22:04:25 -07:00
mikereiche
749c0a84e8 DATACOUCH - 534 Add support for Query annotation 2020-05-28 09:05:00 -07:00
Michael Nitschinger
405df74fa0 DATACOUCH-519 - Docs and small changes for transaction support. 2020-05-08 15:34:17 +02:00
Michael Nitschinger
7773a19e42 DATACOUCH-531 - Add license headers to missing files. 2020-05-06 15:10:22 +02:00
Michael Nitschinger
e262a05184 DATACOUCH-519 - Apply formatting for changes 2020-05-06 10:35:04 +02:00
mikereiche
e8e13ffebc DATACOUCH-519 - Reinstate template auditing
This reinstates the auditing that was present before the major
refactoring. Additional testing for createdBy, createdDate,
lastModifiedBy, lastModifiedDate has been added as well.
2020-05-06 10:32:11 +02:00
Michael Nitschinger
b1ed8941bb DATACOUCH-504 - Make sure reactive repositories can be used
This changeset fixes an issue where while blocking repositories would
work properly, the reactive repositories won't. This has been an
oversight in the transition before RC1.
2020-04-19 07:14:59 +02:00
Michael Reiche
0c0dc21f8e DATACOUCH-515 implement additional operators in N1qlQueryCreator and QueryCriteria (#213)
Co-authored-by: mikereiche <michael.reiche@couchbase.com>
2020-04-07 16:45:53 +02:00
Michael Nitschinger
f950e4648a DATACOUCH-504 - Reintroduce query index generation
This changeset reintroduces automatic n1ql index generation but through
new annotations: QueryIndexed and CompositeQueryIndex (as well as
CompositeQueryIndexes to supply more than one). They are translated
into create index statements and executed at startup if configured
in the config.

Note that automatic index management is disabled by default but can
be overidden with a simple flag on the config override. More features
to come later.
2020-03-17 15:05:41 +01:00
David Kelly
c9a19c925e DATACOUCH-504 - Migrate to Couchbase SDK 3 2020-03-17 15:04:37 +01:00
Mark Paluch
e944081b94 DATACOUCH-498 - Update copyright years to 2020. 2020-01-07 08:43:29 +01:00
David Kelly
f69d51586d DATACOUCH-484 - Thread safety issue using findBy.
Support for positional parameters necessitated caching them, however
that was not done in a threadsafe fashion.  ThreadLocal storage is
sufficient to take care of the issue.  Added test for it while at it.
2019-11-13 08:37:17 -07:00
David Kelly
4a8e07f8fd DATACOUCH-479 - Fix issue with testcontainers usage.
After updating the POM to not have a fixed testcontainers version, we
discovered the tests were failing with later versions of testcontainers.  It
seems that they updated how they did WaitStrategy, deprecating the old way, so
our WaitStrategy was not being called.  That means no setup was done to
the cluster (passwords, buckets, etc...).  Simple fix was to move to the
new interface.
2019-11-08 08:32:05 -08:00
Mark Paluch
e1460dd8d2 DATACOUCH-485 - Migrate tests to AssertJ. 2019-10-14 14:56:01 +02:00
David Kelly
35c72238cb DATACOUCH-475 Couchbase builds failing.
There was an integration test which wasn't named properly, and
so it was running with regular tests.  This left the container
around, and all subsequent integration tests failed.  Simple
fix.
2019-08-15 14:11:29 -07:00
David Kelly
98a4999f37 DATACOUCH-383 - RxJavaCouchbaseTemplate should return generated id when saving.
Seems we fixed this for the non-Rx version, but not the RxJava version.  Followed
same basic strategy which was used for version, added a simple test.
2019-08-01 09:58:32 -07:00
David Kelly
4341edf941 DATACOUCH-462 - ReactiveCouchbaseRepository count() will raise exception when bucket is empty.
Small cleanup in the deleteAll test (which actually tests this as well), while
we are there.

Also, removed an unused import
2019-06-28 10:21:41 -06:00
David Kelly
64a91f1eb6 DATACOUCH-356 Fix cast issue in deleteAll (#201)
Plus a test.  I didn't notice that Douglas Six did basically the
same thing in another PR (this was a re-do of an earlier PR which
didn't quite do what we'd like).  So since I already had it done
and had a test, I closed that PR (#163) and added him to the author
list.

Also - repository.count() raises a NoSuchElementException after you
delete all the documents.  That seems like a bug, but we will deal
with that separately.
2019-06-26 16:37:11 -06:00
Johannes Jasper
55235b2bc2 DATACOUCH-206 - Provides a way to set distinct consistency on repository methods.
* add @WithConsistency annotation
* evaluate it and set consistency in AbstractN1qlBasedQuery
* evaluate it and set consistency in ReactiveAbstractN1qlBasedQuery
* add documentation on @WithConsistency

Original pull request: #198.
2019-06-26 21:48:01 +02:00
David Kelly
7b3352e8db Fix test issue which only shows up in java 11 (#199)
Seems that LocalDateTime now has microseconds, so the comparison of the unconverted
and converted LocalDateTime will fail, since the conversion/mapping only retains
millisecond precision.
2019-06-21 09:30:55 -07:00
Mark Paluch
abee71cf54 DATACOUCH-439 - URL Cleanup. 2019-06-05 11:34:54 +02:00
David Nault
67479aa756 DATACOUCH-452 - SimpleCouchbaseRepositoryIntegrationTests fails
Ignore the flaky test until we can investigate cause of failure.
2019-05-22 11:28:22 -07:00
David Nault
9080c2dede DATACOUCH-451 - Should be able to run integration tests and all unit tests
This change enables running the integration tests with the command:

    mvn verify

Update the integration tests so they compile and pass. Rename them according
to Spring Data convention (*IntegrationTests.java) so they are executed by the
failsafe plugin instead of the surefire plugin. Move them to same folder as
unit tests according to Spring Data convention.

Update the surefire plugin configuration to include unit tests in classes
named `*Test` as well as `*Tests`. Prior to this change about half of the unit
tests were being ignored.

Integration test changes
========================

Use static factory methods for Sort and PageRequest instead of calling the
constructors which are now private.

Import EvaluationContextExtension from its new package. Remove reference to
deprecated EvaluationContextExtensionSupport.

Retry all calls to `getRepository` because otherwise they may fail due to
concurrent index creation.

Fix test `shouldDeriveViewParameters` to assume results are unordered.

Fail fast if the `server.properties` resource is missing.

Increase query and view timeouts; container is a big sluggish sometimes.
2019-05-20 18:46:21 -07:00
Spring Operator
2f4500e9c7 DATACOUCH-439 - URL Cleanup.
This commit updates URLs to prefer the https protocol. Redirects are not followed to avoid accidentally expanding intentionally shortened URLs (i.e. if using a URL shortener).

# Fixed URLs

## Fixed Success
These URLs were switched to an https URL with a 2xx status. While the status was successful, your review is still recommended.

* [ ] http://www.apache.org/licenses/ with 1 occurrences migrated to:
  https://www.apache.org/licenses/ ([https](https://www.apache.org/licenses/) result 200).
* [ ] http://www.apache.org/licenses/LICENSE-2.0 with 219 occurrences migrated to:
  https://www.apache.org/licenses/LICENSE-2.0 ([https](https://www.apache.org/licenses/LICENSE-2.0) result 200).

Original Pull Request: #195
2019-03-22 11:19:57 +01:00
Subhashni Balakrishnan
e1e4385896 DATACOUCH-438 - Move off deprecations in Spring Data Commons.
Remove stray import IsNewStrategyFactory. This has been removed from commons and causing build failure.

Related ticket: DATACMNS-1496.
2019-03-13 19:01:26 +01:00
Subhashni Balakrishnan
580a50b40f DATACOUCH-388 Add support for ANSI-JOIN across entities
Motivation
----------
To support ANSI JOIN across associated entities

Changes
-------
N1qlJoin annotation on an associated entity field is discovered by the
couchbaseTemplate, which uses N1qlJoinResolver to build and resolve the
query. The query can be resolved eagerly or lazily based on the fetch
type configuration. The retrieved results are then mapped to the
associated entity. In the lazy resolver, a proxy is set on the property
which resolves on the first access.

Results
-------
Verified by unit and integration tests. ANSI join is now possible across
entities.

Original PR: #174
2019-02-12 09:56:58 -08:00
Mark Paluch
f4116f6de6 DATACOUCH-425 - Update copyright years to 2019. 2019-01-02 12:31:10 +01:00
Subhashni Balakrishnan
c4491dc8b4 DATACOUCH-413 Use parameterized queries for Query derivation
Changes
-------
- N1ql query creators implement an interface which provides the place
holder values.
- The query creator uses a position index counter to inject place holders in
the statement created and caches the place holder values in an array.
- Repository query constructor passes the generated query statement
and place holder values to query through the SDK.
- Cleanup N1ql integration tests for count validation and also add
couple of more tests

Results
-------
The testing for changes are already covered under the modified existing tests
in N1qlQueryCreator and Repository.
2018-11-26 11:23:14 -08:00
Subhashni Balakrishnan
9840acd2c6 DATACOUCH-384 - Apply converters to string based query parameters
Apply the converters registered to serialize the positional and named
parameters to match the database representation

Original Pull Request: #172.
2018-11-07 14:39:11 -08:00
Subhashni Balakrishnan
e360c23d92 DATACOUCH-376 - Apply custom conversions for collection elements
Original Pull Request: #164.
2018-07-16 11:10:43 -07:00
Subhashni Balakrishnan
076dcc0219 DATACOUCH-389 - Update to Couchbase-Java-Client 2.6.0
Added the new committed environment configurables to the xml based
configuration parser info. Also added couchbase FLE encryption library as bean
instantiation introspects class methods and fails with ClassNotFound
exception.

Original Pull Request: #165.
2018-07-16 10:25:56 -07:00
Oliver Gierke
b18761b409 DATACOUCH-373 - Adapt to API changes in Spring Data Commons.
Related tickets: DATACMNS-1275.
2018-04-09 14:56:27 +02:00
Subhashni Balakrishnan
0960f11a9c DATACOUCH-322 - Add RBAC username and password support
Motivation
----------
Couchbase server 5.0 allows role based access control and this allows
for users to be created and granted access to use bucket. Expose this
feature in SDC.

Changes
-------
1. Couchbase configurations allow for user name to be set. The user password
property is still retrieved from bucket password property.
2. CouchbaseFactoryBean has additional constructor for the username
property.
3. Couchbase bucket schema for xml configurations also includes username
property.
4. Integration tests have been restructured majorly to accomadate for
username
    - Testcontainers are used to allow for container based testing.
    - Container based testing is optional, it can be configured using
      resources/server.properties

Results
-------
The RBAC change has been tested with pre 5.0 and 5.0+ versions using
containers. The tests pass.

Original pull request: #158.
2018-03-07 15:09:15 -08:00