Commit Graph

227 Commits

Author SHA1 Message Date
Mark Paluch
94e6308123 DATACOUCH-650 - Polishing.
Reorder methods. Remove superfluous final keyword. Reformat pom. Fix dependency to Spring Data Commons.

Original pull request: #279.
2020-11-25 11:48:04 +01: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
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
ed02ed535e DATACOUCH-632 - Fix compilation error introduced in DATACOUCH-603. (#269)
Co-authored-by: mikereiche <michael.reiche@couchbase.com>
2020-10-09 18:04:03 -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
ae43ed9949 DATACOUCH-604 - Fix NullPointerException when identifying Id fields. Handle @Field. 2020-09-16 13:46:48 -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
4a52268f19 DATACOUCH-604 - Fix NPE when looking for Id field in interface.
This was failing with a repository for the domain object CouchbaseOAuth2AccessToken.
The following dependency is needed.

        <dependency>
            <groupId>org.springframework.security.oauth</groupId>
            <artifactId>spring-security-oauth2</artifactId>
            <version>2.4.1.RELEASE</version>
        </dependency>

package org.springframework.data.couchbase.domain;

import org.springframework.data.annotation.Id;
import org.springframework.data.couchbase.core.mapping.Document;
import org.springframework.data.couchbase.core.mapping.Field;
import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken;
import org.springframework.security.oauth2.common.OAuth2AccessToken;

@Document(expiry = 30 * 24 * 60 * 60)
public class CouchbaseOAuth2AccessToken extends DefaultOAuth2AccessToken {

	private static final long serialVersionUID = 6537949925775752989L;

	@Id
	private String tokenId;

	@Field
	private String authentication;

	@Field
	private String authenticationKey;

	@Field
	private String clientId;

	@Field
	private String userName;

	// getters and setters omitted for brevity

	private CouchbaseOAuth2AccessToken() {
		this((String) null);
	}

	public CouchbaseOAuth2AccessToken(OAuth2AccessToken accessToken) {
		super(accessToken);
		this.tokenId = accessToken.getValue();
	}

	public CouchbaseOAuth2AccessToken(String value) {
		super(value);
		this.tokenId = value;
	}

}
2020-09-16 13:04:07 -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
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
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
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
749c0a84e8 DATACOUCH - 534 Add support for Query annotation 2020-05-28 09:05:00 -07:00
Michael Nitschinger
33fdffab2f DATACOUCH-539 - Deprecate annotations before GA
This changeset also brings back deleted annotations so that they
do not cause build issues in other components.
2020-05-11 15:05:53 +02:00
Michael Nitschinger
799fec702c DATACOUCH-538 - Add scan consistency to analytics query template 2020-05-08 17:01:21 +02: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
b47fc007b5 DATACOUCH-531 - Initial javadoc polish for GA 2020-05-06 14:54:34 +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
af960817e9 DATACOUCH-504 - Apply eclipse formatting rules. 2020-04-19 07:21:35 +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
ad56d48926 DATACOUCH-504 - Optimize shutdown of cluster
Only shut it down on the factory if internally initialized and
make sure we properly close it on the config.
2020-03-17 15:05:44 +01: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
Michael Nitschinger
3bd9635df3 DATACOUCH-509 - remove the configurer again
Boot figured out a better way to handle it, so we can get rid of
it again.
2020-03-17 15:05:34 +01:00
Michael Nitschinger
e100042850 DATACOUCH-504 - Make sure Reactive* repository take the reactive operations. 2020-03-17 15:05:30 +01:00
Michael Nitschinger
573e389f22 DATACOUCH-509 - Align environment naming in configurer 2020-03-17 15:05:24 +01:00
Michael Nitschinger
e918fa8793 DATACOUCH-509 - couchbaseClientFactory needs to take cluster from configurer 2020-03-17 15:05:20 +01:00
Michael Nitschinger
1ee0045f0e DATACOUCH-509 - Expose only SDK related infos on configurer
Since the client factory is a spring data concept, it cannot be
exposed on the configurer. Only expose the cluster and the environment
on it.

This also modifies the config to populate the right beans from the
configurer methods as well.
2020-03-17 15:05:14 +01:00
Michael Nitschinger
cf67ab44cc DATACOUCH-504 - Make couchbase cache config available.
Spring boot needs to be able to access the cache config on the
CouchbaseCache instance, so make it available.
2020-03-17 15:05:09 +01:00
Michael Nitschinger
daf479b345 DATACOUCH-509 - Restore CouchbaseConfigurer
Since boot needs it for easy mocking/testing, restoring the
configurer (but with the new corresponding beans and only
the subset that is currently available).
2020-03-17 15:05:05 +01:00
Michael Nitschinger
4abad35639 DATACOUCH-504 - More enhancements for spring boot 2020-03-17 15:05:01 +01:00
David Kelly
c9a19c925e DATACOUCH-504 - Migrate to Couchbase SDK 3 2020-03-17 15:04:37 +01:00