Commit Graph

32 Commits

Author SHA1 Message Date
Michael Reiche
b872714be1 Revert to single-module. (#1583)
Closed #1582.
2022-10-10 00:08:11 -07:00
Michael Reiche
a998251585 Reorganize repository so additional modules can be added. (#1514)
Closes #1503.
2022-07-28 15:26:53 -07:00
Michael Reiche
c5efd9a89e Transaction Support for Spring Data Couchbase.
Closes #1145.

commit e2df8e73777a80ea71c15d77dd51252f6766fa94
Author: Michael Reiche <48999328+mikereiche@users.noreply.github.com>
Date:   Mon Jun 27 18:29:23 2022 -0700

    Rebased and tidied transaction branch.

    In addition to transaction support, some inconsitencies in
    fluent APIs were remedied.

    Documentation to follow.

    Closes #1145.

commit e20ed0814e770e26ec34634429f3ac7710acd8d3
Author: Michael Reiche <48999328+mikereiche@users.noreply.github.com>
Date:   Fri Jun 24 17:21:45 2022 -0700

    Rebase with main.

commit edadede7a01997a364c1f5169a36e8bb3e4eee11
Author: Michael Reiche <48999328+mikereiche@users.noreply.github.com>
Date:   Fri Jun 24 10:45:21 2022 -0700

    Add support for Couchbase Transactions.

    The fluent operations are common for options that are common to operations
     with and without transactions.  Once there is a transaction(ctx), or an
    option specific to without-transactions (such as scanConsistency), the
    interfaces are bifurcated, so that an non-transaction option cannot be
    applied to a transaction operation, and a transaction(ctx) cannot be
    applied where a non-transaction option has already been applied.

    Closes #1145.

    Support for @Transactional for blocking and reactive Transactionmanager.

    Closes 1145.

    Transaction Support.

    Transaction Support.

    Porting to SDK-integrated version of transactions

    The transactions logic exists in the Java SDK as of 3.3.0,
    with a slightly different API.

    This is the first effort at the port, which literally just
    compiles.  It will not run as crucial code has been
    commented and todo-ed.  There is work remaining to figure
    out how to complete the port, as some crucial parts (such
    as ctx.commit() and ctx.rollback()) have been intentionally
    removed.

    Continuing work to get the ExtSDKIntegration port working

    Trying to transition to CallbackPreferring manager.

    Added CouchbaseSimpleCallbackTransactionManager, the simplest
    possible implementation of CallbackPreferringTransactionManager,
    combined with a simpler approach to ThreadLocal storage in
    ReactiveInsertByIdSupport.

    Test 'commitShouldPersistTxEntriesOfTxAnnotatedMethod' is now
    passing.

    Adding WIP get-and-replace @Transactional support

    (Not yet working as CAS/version field in
    Person is not populated correctly.)

    Datacouch 1145 transaction support (#1423)

    * Porting to SDK-integrated version of transactions

    The transactions logic exists in the Java SDK as of 3.3.0,
    with a slightly different API.

    This is the first effort at the port, which literally just
    compiles.  It will not run as crucial code has been
    commented and todo-ed.  There is work remaining to figure
    out how to complete the port, as some crucial parts (such
    as ctx.commit() and ctx.rollback()) have been intentionally
    removed.

    * Continuing work to get the ExtSDKIntegration port working

    Trying to transition to CallbackPreferring manager.

    * Added CouchbaseSimpleCallbackTransactionManager, the simplest
    possible implementation of CallbackPreferringTransactionManager,
    combined with a simpler approach to ThreadLocal storage in
    ReactiveInsertByIdSupport.

    Test 'commitShouldPersistTxEntriesOfTxAnnotatedMethod' is now
    passing.

    * Adding WIP get-and-replace @Transactional support

    (Not yet working as CAS/version field in
    Person is not populated correctly.)
    Commit before pulling Graham's changes.

    Merge branch 'datacouch_1145_transaction_support' of github.com:spring-projects/spring-data-couchbase into datacouch_1145_transaction_support

    Transitioning to use CoreTransactionAttemptContext.
    Tests may fail.

    Removing AttemptContextReactiveAccessor

    Don't think we need this, as we can pass around
    CoreTransactionAttemptContext instead, which gives
    access to a lot of internals.

    Removing TransactionsReactive

    Would prefer not to C&P a huge class out of the transaction
    internals, and don't think we need it.

    Removing some files not currently used

    To reduce & simplify the amount of code to look at.

    Some don't seem to be used in any branch, some just
    aren't used in this branch.

    Removing CouchbaseTransactionInterceptor

    As per offline discussion, CallbackPreferringPlatformTransactionManager
    is perhaps the optimal solution.

    Copying @Transactional tests out into separate class

    Tidyup

    Tidyup test names

    Verify GenericSupport is on same thread before and after transactional operation

    Refactoring CouchbaseSimpleCallbackTransactionManager ThreadLocalStorage management

    Using latest java-client

    ReactiveReplaceByIdSupport - Fixing use of CAS now have CoreTransactionAttemptContext.

    Removing unused code.

    ReactiveInsertByIdSupport - fixing use of reactive vs non-reactive, and CAS

    Merging upstream

    Remove incorrect thread check (.doOnNext could execute on a different thread)

    Get scope and collection from pseudoArgs and some cleanup.

    Completing merge from upstream

    Removing unused classes

    Give GenericSupport a better name

    Reject at runtime options that aren't supported in a transaction

    Fixing some small todos, partly by removing unused coe

    Fix runtime option checks

    Simplifying CouchbaseSimpleCallbackTransactionManager ThreadLocalStorage

    Standardising on ReactiveCouchbaseResourceHolder rather than
    holding CoreTransactionAttemptContext too

    Removing version from CouchbaseDocument

    Can't recall why I added this, and tests pass without it

    Improving CouchbaseTransactionalIntegrationTests and adding more tests

    Reject operations that aren't allowed in a transaction (upsertById etc.)

    Improve handling of CAS mismatch

    By calling CoreTransactionAttemptContext.operationFailed,
    it ensures that internal state is set.  So even if
    the user catches the exception, the transaction still behaves
    as it should.

    Removing a now-redundant non-transactional check on upsertById

    I missed this when adding TransactionalSupport.verifyNotInTransaction
    here.

    Support @Transactional options timeout and isolation level

    Add ReactiveTransactionWrapper/TransactionWrapper and a bunch of cleanup.

    Merge branch 'datacouch_1145_transaction_support' of https://github.com/programmatix/spring-data-couchbase into programmatix-datacouch_1145_transaction_support

    Fixed up merge issues.

    Datacouch 1145 transaction support (#1447)

    * Move CouchbaseTransactionalOperator to use SLF4J, same as
    rest of the code.

    * Handle all propagation levels

    * Adding new tests for repository calls inside @Transactional

    One test is failure due to what looks like a bug elsewhere.

    * Rename CouchbaseTransactionalIntegrationTests, and check
    after each test that we're not in a transaction.
    Remove unnecessary methods From ReactiveCouchbaseClientFactory.

    Also rationalized naming of methods and other changes.

    Cleanup of test classes.

    Datacouch 1145 transaction support (#1448)

    * Move CouchbaseTransactionalOperator to use SLF4J, same as
    rest of the code.

    * Handle all propagation levels

    * Adding new tests for repository calls inside @Transactional

    One test is failure due to what looks like a bug elsewhere.

    * Rename CouchbaseTransactionalIntegrationTests, and check
    after each test that we're not in a transaction.

    * Remove unnecessary methods From ReactiveCouchbaseClientFactory.

    Also rationalized naming of methods and other changes.

    * Cleanup of test classes.

    * Removing unused classes

    (Reducing the cognitive burden)

    * Removing version from CouchbaseDocument

    This change was done previously - it must have slipped back in
    a merge.

    * Adding and removing TODOs

    * Adding and removing TODOs

    * DRYing CouchbaseTransactionalPropagationIntegrationTests

    * Check propagation tests retry as expected

    * Tidy up PersonWithoutVersion to the minimum required

    * Removing unused code

    This should all be non-destructive.  Just removing code IntelliJ
    declares unused.  Intent is to make it easier to figure out
    how the CoreTransactionAttemptContext TLS is working.

    * Adding tests for @Transactional removeByQuery and findByQuery

    Failing as they aren't being executed transactionally - investigating why.

    Co-authored-by: Michael Reiche <48999328+mikereiche@users.noreply.github.com>
    change references to resource holder

    change refs to resource holder

    Merge branch 'programmatix-datacouch_1145_transaction_support' of github.com:spring-projects/spring-data-couchbase into programmatix-datacouch_1145_transaction_support

    Removing core transaction attempt context bound couchbase client factory rebased (#1449)

    * Move ReactiveTransactionsWrapper tests into a new file

    * (Temporarily?) disabling tests using CouchbaseTransactionOperation or TransactionalOperator

    As I feel we should be removing/not-supporting these, and
    on this branch I've broken them.

    * Make all transaction tests call assertNotInTransaction

    * Removing unused code

    * Instead of binding the transaction AttemptContext to a
    CouchbaseClientFactory, fetch it from ThreadLocalStorage
    (or the reactive context) instead.

    This allows a lot of simplifying:
    * The non-trivial ReactiveCouchbaseClientUtils can be removed
    * As can CoreTransactionAttemptContextBoundCouchbaseClientFactory

    Also removing TransactionalSupport.one as it wasn't providing
    as much DRY utility as I thought it would - only used in two
    places.

    This change won't compile on its own.  To reduce the complexity
    of this patchset, the Reactive*OperationSupport changes will
    go into a separate commit.

    * Reactive*OperationSupport changes to support the previous commit.

    * Fixing ReactiveRemoveByQuerySupport.

    Both to support the changes to TransactionalSupport.
    And to fix the TODO where the query resuls were
    not being handled.

    * Disabling a test

    * Adding CouchbaseTransactionsWrapperTemplateIntegrationTests

    * Another advantage of removing CoreTransactionAttemptContextBoundCouchbaseClientFactory
    is we can remove Cluster and ClusterInterface.

    * Adding CouchbaseReactiveTransactionsWrapperTemplateIntegrationTests

    Some of these tests are currently failing - tracking down where the
    issue is.
    Merge branch 'programmatix-datacouch_1145_transaction_support' of github.com:spring-projects/spring-data-couchbase into programmatix-datacouch_1145_transaction_support

    manual merges for PR

    manual merges for PR

    Fix a bunch of test cases and remove unused bits.

    Removing CouchbaseTransactionInterceptor

    As discussed on Slack.

    Reenabling some tests that are passing

    (Unclear why these were disabled?)

    Verified that CallbackPreferringPlatformTransactionManager getTransaction/commit/rollback are never called

    Adding tests for TransactionTemplate, which works fine with CouchbaseSimpleCallbackTransactionManager

    Whether we actually document this support is another matter - it's
    yet another way of doing transactions.

    Small fixes to support TransactionTemplate

    * Handle if the user has set isRollbackOnly on the TransactionStatus
      (which is only available - I think - when using TransactionTemplate)
    * Supply a `transaction` object to CouchbaseTransactionStatus so that
      status.isNewTransaction() correctly returns true.  (This method requires
      that transaction to be set.)

    Clarifying that direct use of PlatformTransactionManager is not supported

    Adding further TransactionTemplateIntegrationTests tests

    Fixing removeByQuery queryOptions creation

    Removing now-fixed TODO (no longer key off Cluster)

    Adding overload to CouchbaseSimpleCallbackTransactionManager to allow
    it to be constructed without a TransactionOptions.

    Adding CouchbaseSimpleTransactionalOperator, the simplest possible
    implementation of TransactionalOperator.

    Adding retry tests

    Just making sure that error handling and retries are done correctly throughout.

    Updating and adding some TODOs

    Have CouchbaseTransactionManager support CouchbaseResourceHolder.class binding

    Adding more tests for CouchbaseTransactionManager.

    These tests fail, and are known to fail.  I'm adding them as a solid demonstration of
    why I don't feel we can have this CouchbaseTransactionManager: it doesn't
    provide the crucial 'core loop' functionality, including error handling
    and retries.  We should standardise on CouchbaseSimpleCallbackTransactionManager
    instead.

    CouchbaseSimpleCallbackTransactionManager.executeNewReactiveTransaction now
    buffers results rather than trying to stream a Flux from out of a
    completed lambda (which I doubt is even possible.)

    Removing comment that has been resolved.

    (As per Slack, we will live with this limitation.)

    Adding CouchbaseSimpleTransactionInterceptor, a very
    simple TransactionInterceptor implemention that
    defers to CouchbaseSimpleCallbackTransactionManager
    if that is the provided TransactionManager, and otherwise
    just calls super.

    This allows reactive @Transactional - though all
    @Transactional methods including blocking will now flow
    through it.

    There are two rather divergent approaches in the code currently:

    1. CouchbaseTransactionManager, ReactiveTransactionManager, CouchbaseTransactionalOperator, CouchbaseTransactionInterceptor
    2. CouchbaseSimpleCallbackTransactionManager, CouchbaseSimpleTransactionalOperator, CouchbaseSimpleTransactionInterceptor

    I know the intent is to remove some aspects of (1), but until
    that's done it's proving tricky to have tests for both
    concurrently - I've hit several issues on adding
    CouchbaseSimpleTransactionInterceptor, with 'multiple
    transaction manager beans in config' being common.

    So, temporarily moving some beans from
    AbstractCouchbaseConfiguration into the test Config class,
    renaming it, and having two separately TransactionsConfig classes
    for the two approaches.

    Once we've aligned the approaches more, can move what beans
    survive back into AbstractCouchbaseConfiguration.

    Safety check in CouchbaseSimpleCallbackTransactionManager
    that the blocking run is not accidentally
    running a reactive @Transactional somehow.

    Adding tests for reactive @Transactional, which now works
    (including error handling and retries)  as of the
     CouchbaseSimpleTransactionInterceptor.

    With TransactionsConfigCouchbaseSimpleTransactionManager change,
    can now simplify @Transactional(transactionManager = ...) to
    just @Transactional.

    Tidying TODOs

    I saw in a PR comment that getResources no longer uses TransactionOptions

    Removing configureTransactions from config

    As per PR discussion

    Removing some code that has now been refactored into 3.3.1 SDK

    Removing TODOs that are TODONE already

    Removing transactionsOptions() bean from AbstractCouchbaseConfiguration.

    As per comment, this feels unnecessary: any options you'd configure at
    this config level, you'd surely provide at the global (Cluster) level
    instead?

    Reinstating some commented-out code

    This looks pretty crucial - can't recall why I commented it in first place

    Removing TransactionResult

    This was from a now-abandoned idea of storing transactional
    metadata in the entity class.

    Fix recent removal of TransactionOptions bean

    Switch some IllegalStateException for more accurate UnsupportedOperationException

    Tidying tests to remove old GenericApplicationContext method

    Tidying some TODOs

    (todo gp == in code that I think we should remove)
    (todo gpx == needs looking at)

    Tidying TransactionsConfigCouchbaseSimpleTransactionManager

    Provide SpringTransactionAttemptContext and ReactiveSpringTransactionAttemptContext wrappers

    For use by TransactionsWrapper and reactive equivalent.

    Pro: it's an abstraction layer.  It lets us add Spring-specific functionality, or hide
        functionality that for whatever reason doesn't work with Spring
        (which is why it's composition rather than inheritance, beyond that being
        a best practice anyway).

    Con: any new API added will also have to be added to these wrappers.  But
        that's a small amount of work and API is added very infrequently.

    Cleanup tests mostly.  Temporary fix for CouchbaseSimpleCallbackTransactionManager.

    Merge branch 'programmatix-datacouch_1145_transaction_support' of github.com:spring-projects/spring-data-couchbase into programmatix-datacouch_1145_transaction_support

    Tidying up test cases.

    Fixes to over-zealous manual merging.

    - keep CouchbaseTransactionManager as Graham is still using it.
    - fix tests that were expecting SimulateFailure to be nested.

    Add ReactiveTransactionWrapper and enable tests that use it.

    More tidying. Removed CouchbaseTransactionManager.

    Only wrap exceptions in CouchbaseSimpleTransactionInterceptor if they are not RuntimeExceptions.

    Removed CouchbaseTransactionalOperator and ReactiveCouchbaseTransactionalOperator.

    Fixed non-transactions regression introduced in previous commit.

    Removing the two transactions config classes

    Now we've landed on a single agreed approach there's no
    need for this separation any more, and any beans can be
    moved back into AbstractCouchbaseConfiguration.

    Rename CouchbaseSimpleTransactionInterceptor

    The "Simple" moniker is no longer useful since we now
    only have one of these.

    Rename CouchbaseSimpleCallbackTransactionManager

    The "Simple" moniker is no longer useful since we now
    only have one of these.

    Rename CouchbaseSimpleTransactionalOperator

    The "Simple" moniker is no longer useful since we now
    only have one of these.

    Change CouchbaseTransactionalOperator construction to static

    As per Slack discussion.

    Remove comments related to another database

    Removing a test comment that doesn't seem to apply anymore

    Test passes for me at least

    Simplify TransactionsWrapper and AttemptContextReactiveAccessor

    newCoreTranactionAttemptContext is reimplementing some code
    from core plus has some config bugs to resolve.  I think it's
    simpler to remove it and replace TransactionsWrapper
    (the only code still using this method) with the simple code
    seen now.

    (Note this is similar to how I had it before
    1701183b63
    - not sure if that commit intentionally reverted things?)

    This change also petmits a lot of tidyup & simplification throughout
    the codebase.  We can just create CouchbaseResourceHolders
    directly now.

    Tidying a test

    No longer needs retryWhen now using the new approaches

    Remove ReactiveCouchbaseClientFactory.

    It was added to support getting the transaction from the
    TransactionSynchronizationManager.forCurrent() and providing a template
    with a session containing the transaction.

    Fixing some code warnings

    Mostly removing unused code

    Mark internal classes @Stability.Internal

    Removing some tests that have already been previously moved into another file.

    Removing the transaction wrappers

    Requires JVMCBC-1105 and 3.3.2

    Add more tests for native SDK transactions

    Move all tests related to native SDK transactions into their own package

    It makes it easier to test just that functionality
    while iterating.

    Removing CouchbaseTransactionManagerTransactionalTemplateIntegrationTests

    This test is now redundant.  It was created to show
    why the original CouchbaseTransactionManager couldn't work
    (no retries).  Now that has been replaced, this test
    is just duplicating others.

    Adding some minimal JavaDocs and comments.

    Tidying up after moving ThreadLocalStorage into SDK

    Deleting CouchbaseTemplateTransactionIntegrationTests

    As this relies on Spring test @Transactional, which
    we do not support as that Spring logic is not aware
    of CallbackPreferringTransactionManager.

    Removed some redundant bean names

    Tidying up tests and comments

    Removing some now-unused reflection code

    Starting with mapping TransactionFailedException and
    TransactionCommitAmbiguousException, into new errors
    TransactionSystemUnambiguousException and
    TransactionSystemAmbiguousException.

    These will be raised from an @Transactional
    transaction.

    E.g. to do error handling the user would do:

    ```
    try {
       service.transactionalMethod();
    }
    catch (TransactionSystemAmbiguousException ex) {
      // app-specific handling
    }
    catch (TransactionSystemUnambiguousException ex) {
      // app-specific handling
    }

    class Service {
        @Transactional
        void transactionalMethod() {
          // ...
        }
    }
    ```

    Mapping TransactionOperationFailedException, which is
    an opaque signal raised from transaction operations,
    to new exception UncategorizedTransactionDataAccessException.

    This depends on some new functionality added into
    Java SDK 3.3.2, WrappedTransactionOperationFailedException.

    Minor tidyuo

    Improving tests for correct operation-level errors

commit b02959dded4cf19b2f8b6f78b016b5bb6afb9ac8
Author: Michael Reiche <48999328+mikereiche@users.noreply.github.com>
Date:   Mon Mar 14 09:37:51 2022 -0700

    Support derived queries on repositories defined with an abstract entity class. (#1366)

    Motivation:
    Currently an abstract entity class specified in the repository definition can
    be used for the predicate typeKey = typeAlias(of abstract entity class) in
    queries. Since documents are stored with typeKey = typeAlias(of concrete class)
    those queries will never match any documents.  To allow this to work,
    all of the abstract entity class an all concrete subclasses must use the
    same typeAlias.

    Once those documents are found, regardless of their concrete class,
    they will all have the same typeKey = typeAlias, instead of having the
    typeAlias specific to the concrete class. Additional information in
    the stored document is needed to identify the concrete class (subtype
    in the example test case), as well as a TypeMapper to interpret that
     information.

    Changes:
    This allows a common TypeAlias to be used for the purpose of the predicate
    typeKey = typeAlias, and the determination of the concrete type by
    implementing an AbstractingMappingCouchbaseConverter that inspects the
    'subtype' property.

    Closes #1365.

    Co-authored-by: Michael Reiche <michael.reiche@couchbase.com>

commit 5f03d1e0ce80e820ff8a3322b2ebfcf6f1bebb8f
Author: Michael Reiche <48999328+mikereiche@users.noreply.github.com>
Date:   Tue Feb 22 10:09:25 2022 -0800

    Fix update to cache documentation. (#1359)

    Closes #1358.

commit d5ca390d84a281b31854aa201cc53b4093af075d
Author: Michael Reiche <48999328+mikereiche@users.noreply.github.com>
Date:   Tue Feb 22 09:56:53 2022 -0800

    Reinstate CouchbaseCache documentation. (#1357)

    Closes #1356.

commit 9af8ece3708d805c03db8784bfd9cd3c77e76db9
Author: Mark Paluch <mpaluch@vmware.com>
Date:   Tue Feb 22 08:44:34 2022 +0100

    Use Java 17 to build snapshots for Artifactory.

    Closes #1352

commit e83bd41a86528ceb99d2291a23ac07fe6250b75f
Author: Mark Paluch <mpaluch@vmware.com>
Date:   Fri Feb 18 11:15:41 2022 +0100

    After release cleanups.

    See #1307

commit 13d266e6f7ff06901c9359ef7aac5143858d22f1
Author: Mark Paluch <mpaluch@vmware.com>
Date:   Fri Feb 18 11:08:48 2022 +0100

    Prepare 4.4 M3 (2021.2.0).

    See #1307

commit 4a044197aa5d7c4bfc5d9b15f0dc7139bb4b4fc5
Author: Michael Reiche <48999328+mikereiche@users.noreply.github.com>
Date:   Mon Feb 14 09:10:04 2022 -0800

    Add mechanism for save to do one of insert, replace or upsert. (#1316)

    Closes #1277.

commit 1fdbf6d5d091225d3297b3aab892013155000e06
Author: Christoph Strobl <cstrobl@vmware.com>
Date:   Tue Jan 18 09:21:34 2022 +0100

    After release cleanups.

    See #1301

commit da7d241e3927412b5ce32b9a1d017a2412c1891e
Author: Christoph Strobl <cstrobl@vmware.com>
Date:   Tue Jan 18 09:09:02 2022 +0100

    Prepare 4.4 M2 (2021.2.0).

    See #1301

commit ebe33cf138970ad47575452bd8b1fc181964fba7
Author: Christoph Strobl <cstrobl@vmware.com>
Date:   Fri Jan 14 11:08:04 2022 +0100

    After release cleanups.

    See #1298

commit ecadff644c31a834d83c2061cb45edb43f2e8983
Author: Christoph Strobl <cstrobl@vmware.com>
Date:   Fri Jan 14 10:57:51 2022 +0100

    Prepare 4.4 M1 (2021.2.0).

    See #1298

commit 5dbf182fd10c5405b7a9361f50188144b76239b8
Author: Michael Reiche <48999328+mikereiche@users.noreply.github.com>
Date:   Thu Jan 6 15:00:49 2022 -0800

    Incorporate changes from 5.0.x and bump Couchbase SDK. (#1287)

    Closes #1286.

    Co-authored-by: mikereiche <michael.reiche@couchbase.com>

commit ef22b3d7967f805d74ddb92e571899570cd80762
Author: Michael Reiche <48999328+mikereiche@users.noreply.github.com>
Date:   Fri Nov 12 07:15:45 2021 -0800

    Handle Collection<> parameters to repository query methods. (#1271)

    Closes #1270.

    Co-authored-by: mikereiche <michael.reiche@couchbase.com>

commit 00e05e4b41414afd815cf08127da13c2bc3481d1
Author: Jens Schauder <jschauder@vmware.com>
Date:   Fri Nov 12 10:59:45 2021 +0100

    After release cleanups.

    See #1257

commit af66ada42cd19ce8d6ac989188686155d3a8181a
Author: Jens Schauder <jschauder@vmware.com>
Date:   Fri Nov 12 10:49:16 2021 +0100

    Prepare 4.3 GA (2021.1.0).

    See #1257

commit 6ec138182da008c7be465fb5e31f0e210e3b00ca
Author: yyfMichaelYan <54760415+yyfMichaelYan@users.noreply.github.com>
Date:   Mon Nov 8 13:40:24 2021 -0600

    fix flaky test writesAndReadsCustomFieldsConvertedClass (#1264)
2022-06-30 12:14:28 -07:00
Michael Reiche
30a0b8858f Rework the handling of annotations for scope and collection.
The scope and collection repository annotations were not being
passed on to derived and @Query remove operations.

The handling of scope and collection annotations has been reworked in:

1) CrudMethodMetadataProcessor
2) All the *OperationSuppport constructors - the initial scope and collection is
taken from the domainEntity class.
3) PseudoArgs
4) AbstractCouchbaseQuery/AbstractReactiveCouchbaseQuery add the scope/collection
to the remove operation (analogous to the find Operation).
5) Scope/Collection is passed as args to the execute() method - even though this
is redundant at the moment.

Closes #1441.
2022-06-17 12:28:38 -07:00
Michael Reiche
ddfbc1f91d Support testing against Capella. (#1386)
Support testing against Capella. Also includes sample to
use Capella control-plane.

Closes #1385.
2022-04-08 14:36:02 -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
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
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 Nitschinger
fff16bc958 switch to mock by default 2020-03-17 15:05:37 +01:00
David Kelly
c9a19c925e DATACOUCH-504 - Migrate to Couchbase SDK 3 2020-03-17 15:04:37 +01: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
c7bcf811a7 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://maven.apache.org/xsd/maven-4.0.0.xsd with 1 occurrences migrated to:
  https://maven.apache.org/xsd/maven-4.0.0.xsd ([https](https://maven.apache.org/xsd/maven-4.0.0.xsd) result 200).
* http://www.springframework.org/schema/beans/spring-beans.xsd with 10 occurrences migrated to:
  https://www.springframework.org/schema/beans/spring-beans.xsd ([https](https://www.springframework.org/schema/beans/spring-beans.xsd) result 200).
* http://www.springframework.org/schema/context/spring-context.xsd with 4 occurrences migrated to:
  https://www.springframework.org/schema/context/spring-context.xsd ([https](https://www.springframework.org/schema/context/spring-context.xsd) result 200).
* http://www.springframework.org/schema/data/couchbase/spring-couchbase.xsd with 10 occurrences migrated to:
  https://www.springframework.org/schema/data/couchbase/spring-couchbase.xsd ([https](https://www.springframework.org/schema/data/couchbase/spring-couchbase.xsd) result 200).
* http://www.springframework.org/schema/data/repository/spring-repository.xsd with 1 occurrences migrated to:
  https://www.springframework.org/schema/data/repository/spring-repository.xsd ([https](https://www.springframework.org/schema/data/repository/spring-repository.xsd) result 200).
* http://java.sun.com/xml/ns/javaee/beans_1_0.xsd with 1 occurrences migrated to:
  https://java.sun.com/xml/ns/javaee/beans_1_0.xsd ([https](https://java.sun.com/xml/ns/javaee/beans_1_0.xsd) result 302).

# Ignored
These URLs were intentionally ignored.

* http://java.sun.com/xml/ns/javaee with 2 occurrences
* http://maven.apache.org/POM/4.0.0 with 2 occurrences
* http://www.springframework.org/schema/beans with 20 occurrences
* http://www.springframework.org/schema/context with 4 occurrences
* http://www.springframework.org/schema/data/couchbase with 20 occurrences
* http://www.springframework.org/schema/data/repository with 2 occurrences
* http://www.w3.org/2001/XMLSchema-instance with 12 occurrences

Original Pull Request: #188
2019-03-20 10:10:37 +01: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
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
Subhashni Balakrishnan
039e106032 DATACOUCH-362 - Use dynamic proxying
Dynamic proxying for couchbase environment instead of an explicit no shutdown
proxy.

Original pull request: #157.

DATACOUCH-363 - Upgrade to 2.5.5

Java client upgrade. Remove the dcpEnabled property from
CouchbaseEnvironment factory bean and parser.

Original pull request: #157.
2018-03-07 13:26:55 -08:00
Subhashni Balakrishnan
4cca923c59 DATACOUCH-290 - Upgrade to java-client 2.4.4
Original pull request: #136.
2017-04-10 11:33:02 -07:00
Subhashni Balakrishnan
162d8124ab DATACOUCH-260 - Update to 2.4.1 and fix tests
Adapted changes to 3.0 branch

Original pull request: #131.
2017-02-05 13:08:38 -08:00
Simon Bland
a40919ef8e DATACOUCH-235 - Fixed multiple Couchbase environments.
Defining <couchbase:env/> in XML configuration was causing a double
instantiation of DefaultCoreEnvironment, with subsequent warning in
logs:

[main] WARN c.c.client.core.env.CoreEnvironment - More than 1 Couchbase
Environments found (2), this can have severe impact on performance and
stability. Reuse environments!
2016-06-17 15:57:51 +02: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é
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é
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é
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é
4f0ba9d215 DATACOUCH-143 - Log executed queries in DEBUG. 2015-07-16 16:48:45 +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
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
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
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
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
Oliver Gierke
898a892525 DATACOUCH-19 - Polished test setup in preparation for CI setup.
Renamed *Test to *Tests. Reduced connection timeout. Added logback.xml to reduce logging output.
2013-07-29 10:15:24 +02:00
Michael Nitschinger
ab252f8924 DATACOUCH-6 - Add simple support for XML config 2013-07-17 14:58:51 +02:00
Michael Nitschinger
2ed710cfa2 DATACOUCH-6 - add support for xml-based configurations 2013-07-16 14:17:47 +02:00