Commit Graph

204 Commits

Author SHA1 Message Date
Michael Reiche
4c428c5351 Use queryScanConsistency on reactive deleteAll().
It was present on non-Reactive, but missing from reactive.

Closes #1096.
Original pull request: #1108.

Co-authored-by: mikereiche <michael.reiche@couchbase.com>
2021-03-30 17:32:22 -04:00
Michael Reiche
cbcd048f3d Upgrade Couchbase Java SDK to 3.1.3. (#1098)
Closes #1079.

Co-authored-by: mikereiche <michael.reiche@couchbase.com>
2021-03-15 12:12:06 -07:00
Michael Reiche
a142f0895a Revert changes to public apis that were altered instead of just deprecated. (#1093)
Closes #1092.

Co-authored-by: mikereiche <michael.reiche@couchbase.com>
2021-03-05 17:01:58 -08:00
Michael Reiche
8c6598271a Revert "DATACOUCH-550 - Refactored the usage of CouchbasePersistentEntityIndexCreator. (#298)" (#1087)
This reverts commit 80bae4bf67.

Co-authored-by: mikereiche <michael.reiche@couchbase.com>
2021-02-17 09:19:06 -08:00
Michael Reiche
41ee1f99ee DATACOUCH-1066 - Make QueryCriteria key a N1qlExpression. (#1082)
This is a merge of mmonti's changeset into master. The changeset was made
on top of 4.1.x instead of master so it has a little catching up to do.

Co-authored-by: mikereiche <michael.reiche@couchbase.com>
2021-02-16 18:08:06 -08:00
Michael Reiche
6ab350df35 DATACOUCH-1041 - Add withCas() method to RemoveById. (#1051)
Add withCas() method to RemoveById.

Co-authored-by: mikereiche <michael.reiche@couchbase.com>
2021-02-16 15:16:12 -08:00
Jorge Rodríguez Martín
1329cae703 DATACOUCH-652 - Inject translation service bean in CouchbaseTemplateSupport. (#294) 2021-01-15 10:29:14 -08:00
Michael Reiche
ad5551625d DATACOUCH-958 - Restore auditorAwareRef and dateTimeProviderRef to empty. (#1050)
Restore auditorAwareRef and dateTimeProviderRef to empty. To us them, they will need to be specified in
@EnableCouchbaseAuditing( auditorAwareRef="auditorAwareRef", dateTimeProviderRef="dateTimeProviderRef")

Co-authored-by: mikereiche <michael.reiche@couchbase.com>
2021-01-14 16:07:04 -08:00
Michael Reiche
59bf9d7457 DATACOUCH-1048 - Update copyright in two new classes. (#1049)
Update copyright in two new classes.

Co-authored-by: mikereiche <michael.reiche@couchbase.com>
2021-01-14 11:22:15 -08:00
Michael Reiche
0e8d5a255a DATACOUCH-588 - Part 2 of framework changes. Add support for projection and distinct. (#1040)
Support for projection is only for properties of the top-level entity. For instance, in UserSubmission, only the properties below can be specified in the projection. Projection support does not provide means of specifying something like address.street - you can only project (or not project) the whole address property. However, the address type in your resultType could have a subset of the properties in Address.

If the corresponding submissions in the resultType contained only the userId property

public class UserSubmission extends ComparableEntity {
	private String id;
	private String username;
	private List<String> roles;
	private Address address;
	private List<Submission> submissions;

Support for Distinct - I have appropriated the MongoDB model for Distinct.  It defines a separate DistinctOperationSupport class (within ExecutableFindByQuerySupport) which supports the distinct( distinctFields ) api and execution. The DistinctOperationSupport class has only a distinctFields member, and a 'delegate' member, which is an ExecutableFindByQuerySupport object. TBH, I don't see the advantage over simply adding a distinctFields member to ExecutableFindByQuerySupport

Amend #1 - changes as discussed in Pull Request
         - clean up test entity types

Amend #2
- Eliminate DistinctOperationSupport class. In MongoDB, only distinct on a single field is supported, so the returnType from distinct was very different from the returnType of other query operations (all(), one() etc. (but so is count(), and it doesn't need it's own class)). In Couchbase, distinct on any fields in the entity is allowed - so the returned type could be the domainType or resultType. And as(resultType) still allows any resultType to be specified. This makes it unnecessary to have combinations of interfaces such as DistinctWithProjection and DistinctWithQuery.

- Clean up the interfaces in ExecutableFindByQuery. There are two types of interfaces (a) the TerminatingFindByQuery which has the one(), oneValue() first(), firstValue(), all(), count(), exists() and stream(); and (b) the option interfaces (FindByQueryWithConsistency etc), which are essentially with-er interfaces. The changes are:
1) make all the with-er interfaces base interfaces instead of chaining them together. (I don't know why there isn't simply one interface with all the with-er methods).
2) make the ExecutableFindByQuery interface extend the Terminating interface and all the with-er interfaces.

Amend #3
- Add execution support for collections

Amend #4
- Add tests for collections. This includes a new CollectionAwareIntegrationTests class which extends a new JavaIntegratationTests class which extends the existing ClusterAwareIntegrationTests.
- Fixed up several issues collections issues that were uncovered by the tests.
- Did further cleanup of OperationSupport interfaces.

Amend #5
- Revert changes to interfaces in *Operation
- Sorted interfaces in same order for consistency (because of the chaining of interfaces, fluent methods must be called in order).

Co-authored-by: mikereiche <michael.reiche@couchbase.com>
2021-01-14 11:03:20 -08:00
Michael Reiche
3364e0fa7f DATACOUCH-588 - Refactoring part 1 of n. (#278)
* DATACOUCH-588 - Implement pageable and realign repo query

This implements pageable for non-reactive queries and
realigns reactive queries with other spring-data projects
to facilitate the implementaion of pageable (done) and other
types of queries such as projection and distinct (not yet
done)

* DATACOUCH-588 - Implement pageable and realign repo query

This implements pageable for non-reactive queries and
realigns reactive queries with other spring-data projects
to facilitate the implementaion of pageable (done) and other
types of queries such as projection and distinct (not yet
done)

* DATACOUCH-588 - Refactoring part 1 of n.

Co-authored-by: mikereiche <michael.reiche@couchbase.com>
2020-12-21 13:48:50 -08:00
Michael Reiche
9c9dde7312 DATACOUCH-645 - Support document expiryExpression. (#296)
Support document expiryExpression and make the initial expiry
to be null instead of Zero in the fluent API. This allows
a client to 'unset' the expiry from an annotation by explcitly
setting withExpiry(Zero).

Co-authored-by: mikereiche <michael.reiche@couchbase.com>
2020-12-16 15:06:37 -08:00
Michael Reiche
608b013de8 DATACOUCH-675 - Factor out interfaces for common methods. (#293)
Added interfaces for apis on core objects which are common among
many objects. For instance withExpiry and withExpirty on all the
insert/replace/upsert/remove objects.  The definition of an interface
simplyfies testing of all the possible combinations - instead of having
four (or eight, counting Reactive), there is one interface to test
them all.

Co-authored-by: mikereiche <michael.reiche@couchbase.com>
2020-12-14 13:50:04 -08:00
Michael Reiche
662a84bba6 DATACOUCH-672 - reinstate replace expiry tests (#289)
Co-authored-by: mikereiche <michael.reiche@couchbase.com>
2020-12-09 08:44:23 -08:00
Michael Reiche
69e0a1dc33 DATACOUCH-666 - Handle immutable entity in replace. (#288)
Co-authored-by: mikereiche <michael.reiche@couchbase.com>
2020-12-09 08:44:17 -08:00
Michael Reiche
bce764c712 DATACOUCH-630 - Add expiry to replace 4.2.x (#287)
Co-authored-by: mikereiche <michael.reiche@couchbase.com>
2020-12-09 07:56:08 -08:00
Michael Reiche
3c59af3cc8 DATACOUCH-661 - Fix integrations tests from 650. (#281)
Co-authored-by: mikereiche <michael.reiche@couchbase.com>
2020-12-08 00:30:45 -08:00
Jens Schauder
3aeff66a3b DATACOUCH-650 - Implements CrudRepository and ReactiveCrudRepository.deleteById(Iterable<ID> ids).
Original pull request: #279.
2020-11-25 11:47:49 +01:00
Michael Reiche
182d45ab6e DATACOUCH-625 - Save doesn't return updated entity if immutable. (#274)
Modified applyUpdatedCas() to return accessor.getBean() which will
occur if the version property is Immutable.
Created applyUpdateId() that is analogous to applyUpdatedCas()
Factored out the equals() method that was used by a number of
test entity objects.

Co-authored-by: mikereiche <michael.reiche@couchbase.com>
2020-10-22 10:54:43 -07:00
Haris Alesevic
a85720c8f4 DATACOUCH-619 - FindByMatchingQuery integration test
Verify that findByQuery works as expected (fixed as part of DATACOUCH-603)
2020-10-14 14:55:40 -07:00
Michael Reiche
1955cf45cd DATACOUCH-626 - Handle reading into entity with only all-args constructor; version primative type.
The version arg - which is not in the document - will be passed
into the constructor as a null which will fail if it is a primitive
type. This change will pre-populated the converted object with
the version/cas, so that it is not null.

Co-authored-by: mikereiche <michael.reiche@couchbase.com>
2020-10-14 14:54:01 -07:00
Michael Reiche
0ce0f36b49 DATACOUCH-623 - Add replace() method to CouchbaseRepository for CAS usage. (#268)
Co-authored-by: mikereiche <michael.reiche@couchbase.com>
2020-10-12 17:16:01 -07:00
Michael Reiche
7c431d640f DATACOUCH-583 - Nested properties in queries not working. (#270)
The complete property path was being quoted instead of the individual
components.  ie.  `address.street` instead of `address`.`street`
Also fixed another issue - changed the maybeQuote() method for
property names to correctly look for back-tics instead of double
quotes and changed the name accordingly.

Co-authored-by: mikereiche <michael.reiche@couchbase.com>
2020-10-12 13:22:19 -07:00
Michael Reiche
1b5c32150e DATACOUCH-603 Do not cast query parameters in N1qlQueryCreator.
For IN and NOT_IN - they can take varargs, an array or a JsonArray
Don't cast query criteria parameters, let parameter accessor handle that.
Fixed conversion of query criteria values to parameters
Cleaned up QueryCriteria

Co-authored-by: mikereiche <michael.reiche@couchbase.com>
2020-10-09 14:59:16 -07:00
mikereiche
e72cdba6ee DATACOUCH-616 - Fix parsing of String Query containing conditionals in quotes
For a query as below that has conditional portions, the parsing for
parameters was being done before the conditional portions were being
resolved, which left the parameters between quotes where they wre
not being recognized as query parameters.

@Query("#{#n1ql.selectEntity} WHERE #{#n1ql.filter} " +
	" #{#projectIds != null ? 'AND iata IN $1' : ''} ")
Long count(@Param("projectIds") List<String> projectIds)
2020-10-05 10:45:40 -07:00
mikereiche
82edad5759 DATACOUCH-605 - Support ScanConsistency in n1ql queries 2020-10-05 10:14:03 -07:00
Haris Alesevic
fab72ee9c9 DATACOUCH-615 Use query in removeByQuery (#264)
* DATACOUCH-615 Use query in removeByQuery

Use provided query instead of hardcoded statement.

* DATACOUCH-615 Better method naming in Query class

* DATACOUCH-615 Replace hard-coded meta fields

* DATACOUCH-615 Test findByQuery.matching

* DATACOUCH-615 Remove failing test
2020-10-05 10:11:37 -07:00
mikereiche
2a06578145 DATACOUCH-620 - Fix nested object id/@Id issue.
Only treat the id (or @Id) field in top-level objects as the id.
2020-10-05 10:01:15 -07:00
mikereiche
e9add0c90c DATACOUCH-608 - Propagate expiry option and annotation to insert and upsert calls. 2020-09-16 13:06:03 -07:00
mikereiche
23d2f61d45 DATACOUCH-595 - Add cas to replace options if present on entity. 2020-09-11 15:18:27 -07:00
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