Commit Graph

227 Commits

Author SHA1 Message Date
Michael Reiche
7c1167f302 Specifying withExpiry(Duration) on findById() uses getTouchAndRead(). (#1196)
Closes #982.
2021-09-13 11:21:23 -07:00
Michael Reiche
345af53930 Pass source as parent when reading subobject. (#1222)
Closes #1221.

Co-authored-by: mikereiche <michael.reiche@couchbase.com>
2021-09-13 11:11:05 -07:00
Michael Reiche
da3e8e0e36 Support N1QL Join Annotations. (#1211)
* Support N1QL Join Annotations.

Closes #1198.
2021-09-12 18:38:01 -07:00
Michael Reiche
4bd82ea23c Add project(fields) to findByQuery similar to same method on findById. (#1212)
Closes #1208, #1213.
2021-09-12 17:17:47 -07:00
Michael Reiche
bcf11ce856 Support derived queries from methods named findDistinctF1AndF2ByF3() (#1202)
Support derived queries from methods named findDistinctF1AndF2ByF3().

Closes #1200.
2021-08-23 13:51:55 -07:00
Michael Reiche
f0880daf7a Fix ArrayIndexOutOfBoundsException on String queries that use paging. (#1197)
Closes #1155.

Co-authored-by: mikereiche <michael.reiche@couchbase.com>
2021-08-23 13:06:57 -07:00
Michael Reiche
dffd203a57 Remove the sort from query before executing count. (#1194)
Also creates the query with skip and limit from any Pageable parameter instead of applying it later.
Closes #1191.
2021-08-18 09:07:15 -07:00
Michael Reiche
7e2963a365 Throw an explicit exception if count query does not return a count. (#1195)
Also just use the first projected property instead of one explicitly named "count".

Closes #925,#960.
2021-08-18 09:06:43 -07:00
Michael Reiche
07022c1e86 Remove unnecessary auditorAwareRef from test config. (#1189)
Remove unnecessary auditorAwareRef from test config as it causes
confusion. The property does not need to be preset for the auditorAwareRef
bean to be used.
The dateTimeProviderRef must be present for the provided
dateTimeProviderRef bean to be used.

Closes #1052.
2021-08-17 10:35:33 -07:00
Michael Reiche
fada241988 N1ql query should project getFieldName() instead of getName(). (#1185)
Closes #1184.
2021-08-16 13:02:55 -07:00
Michael Reiche
d210678c78 Field(name=myName) annotation work like Field(myName) and Field(value=myName). (#1186)
Closes #1068.
2021-08-16 12:55:02 -07:00
Michael Reiche
52b1832cb5 Expiration annotation on field will retrieve expiration in N1ql queries. (#1188)
Closes #1060.
2021-08-16 12:53:46 -07:00
Michael Reiche
6512fc087b To support jdk 16, add converters and module-info. (#1167)
To support jdk 16, add converters and module-info.

Closes #1057.
2021-08-13 11:28:04 -07:00
Michael Reiche
51b0d32636 Add Transient, Stream and Flux Pair tests. (#1175)
Closes #1174.
2021-08-11 14:45:01 -07:00
Michael Reiche
7d5e33ad71 Handle auto index on field path. (#1169)
Closes #1166.

Co-authored-by: mikereiche <michael.reiche@couchbase.com>
2021-08-11 10:29:05 -07:00
Michael Reiche
9e3bfe5b71 Omit annotations from the repository and domaintype in CrudMethodMetadata. (#1170)
Omit annotations from the repository and domaintype in
CrudMethodMetadata as they may be different for the same method.
The annotations from the repository and domaintype are obtained directly
in CouchbaseRepositoryBase.

Closes #1168.

Co-authored-by: mikereiche <michael.reiche@couchbase.com>
2021-08-10 20:17:12 -07:00
Michael Reiche
7cde6b919e Scopes and collections for repositories (#1149)
* Add support for scopes and collections for repositories.

Adds DynamicProxyable and DynamicInvocationHandler to
set scope/collection/options on PseudoArgs when calling
operations via repository interfaces.

Closes #963.

Co-authored-by: mikereiche <michael.reiche@couchbase.com>
2021-08-09 09:57:29 -07:00
Michael Reiche
155663e66f Add missing hooks for callbacks. (#1142)
1) the previous change (#955) to CouchbaseAuditingRegister intended to register
 AuditingEntityCallback instead of AuditingEventListener but only changed the
name that AuditingEventListener was registered with. Since
AuditingEventListener does exactly the same thing as AuditingEntityCallback,
it behaved as those AuditingEntityCallback was being used.

2) It seems that the two mechanisms - EntityCallback and EventListener
both do more-or-less the same thing. I'm not sure why there are two
mechanisms to do the same thing.

3) Although the ReactiveAuditingEntityCallback mechanism is triggered
only for reactive operations and the non-reactive AuditingEntityCallback
is triggered only for non-reactive operations, the events are triggered
for both. Since there was a desire to have distinct callbacks for
reactive/non-reactive operations, I also made distinct events for
reactive/non-reactive operations.  However both the reactive and non-reactive
event mechanisms are triggered for either reactive and non-reactive operations,
so it is necessary for the mechanism to determine if it should act on the
event.

4) Although there is an AbstractCouchbaseEventListener that is extended by
LoggingEventListener and ValidatingEventListener, AuditingEventListener does
not extend it (maybe it should).

Closes #1074.

Co-authored-by: mikereiche <michael.reiche@couchbase.com>
2021-06-09 21:54:24 -04:00
Michael Reiche
67a7937cd2 Improve framework for custom mapping couchbase converter. (#1148)
1) change examples in Config to show creating repository mappings using
existing MappingCouchbaseConverter (which have customConversions /
BeanNames.COUCHBASE_CUSTOM_CONVERSIONS and applicationContext)
instead of creating their own and then adding the customConversion and
applicationContext.

2) replace @Autowired couchbaseObjectMapper with couchbaseObjectMapper()
to avoid the following when using @ComponentScan :
Unsatisfied dependency expressed through field 'couchbaseObjectMapper';
nested exception is org.springframework.beans.factory.
BeanCurrentlyInCreationException: Error creating bean with name
'couchbaseObjectMapper': Requested bean is currently in creation: Is
there an unresolvable circular reference?

3) remove unused members fro StringBasedN1qlQueryParser

Closes #1141.

Co-authored-by: mikereiche <michael.reiche@couchbase.com>
2021-06-09 21:36:45 -04:00
Michael Reiche
43889e6a9c Scope and collection API for template. (#1133)
Scope and Collection API for template.

Closes #963.
Original pull request: #1071.
2021-06-02 09:38:02 -04:00
Michael Reiche
a80663119c Expose ObjectMapper used by JsonSerializer (#1132)
Closes #1130.

Co-authored-by: mikereiche <michael.reiche@couchbase.com>
2021-05-05 12:16:38 -07:00
Michael Reiche
36de313466 Add override of toN1qlRemoveString() to StringQuery. (#1135)
Closes #1131.
Original pull request: #1135.

Co-authored-by: mikereiche <michael.reiche@couchbase.com>
2021-05-04 07:25:18 -07:00
Jorge Rodríguez Martín
3f1cea174f Add support for reactive auditing and ReactiveEntityCallbacks.
Add support for reactive auditing and ReactiveEntityCallbacks.
Also, adapt CouchbaseAuditingRegistrar for support AuditingEntityCallback.

Closes #955.
Original pull request: #1102.

Co-authored-by: Carlos Espinado <carlosemart>
Co-authored-by: mikereiche <michael.reiche@couchbase.com>
2021-04-06 11:58:42 -04:00
Michael Reiche
5a04711a6d DefaultCouchbaseTypeMapper uses TypeAlias annotation if present.
DefaultCouchbaseTypeMapper uses TypeAlias annotation if present.
Test case also uncovered that TypeAlias was being ignored for
string queries.

Closes #1119.
Original pull request: #1120.

Co-authored-by: mikereiche <michael.reiche@couchbase.com>
2021-04-06 08:13:50 -07:00
Michael Reiche
9b848f6254 Specific message for string queries that do not project __id and __cas.
com.couchbase.client.core.error.CouchbaseException: query did not project __id.
 Either use #{#n1ql.selectEntity} or project __id and __cas :
 SELECT __cas, * from `b406ab45-ef95-441f-a318-76b8e8af2d76` where iata = $1

Closes #1097.
Original pull request: #1114.

Co-authored-by: mikereiche <michael.reiche@couchbase.com>
2021-04-06 08:03:02 -07:00
Michael Reiche
2e8d655751 Fix N1QLExpression keys.
Fix syntax of N1QLExpression keys.

Closes #1064.

Co-authored-by: mikereiche <michael.reiche@couchbase.com>
2021-03-31 06:10:42 -07:00
Michael Reiche
d16bbff4fe Support enum arguments on repository queries.
Support enum in AbstractCouchbaseConverter.convertForWriteIfNeeded()
and also call that from
MappingCouchbaseConverter.getPotentiallyConvertedSimpleWrite()

Closes #1069.
Original pull request: #1112.

Co-authored-by: mikereiche <michael.reiche@couchbase.com>
2021-03-30 17:32:22 -04:00
Michael Reiche
fe8d3feb48 Add QueryCriteria arrayContaining.
Add QueryCriteria arrayContaining which maps to n1ql array_containing.

Closes #1073.
Original pull request: #1109.

Co-authored-by: mikereiche <michael.reiche@couchbase.com>
2021-03-30 17:32:22 -04:00
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