From 029bf2fcedbcfd9186ce49a8de7a7ab7c3b09ea6 Mon Sep 17 00:00:00 2001 From: AB Date: Mon, 21 Oct 2024 08:56:12 +0200 Subject: [PATCH 01/54] Don't fail on broken links --- .github/workflows/broken-links.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/broken-links.yml b/.github/workflows/broken-links.yml index c17c3978..48265e89 100644 --- a/.github/workflows/broken-links.yml +++ b/.github/workflows/broken-links.yml @@ -19,6 +19,8 @@ jobs: - name: Link Checker id: lychee uses: lycheeverse/lychee-action@v2 + with: + fail: false # Don't fail on broken links, create an issue instead - name: Find already existing issue id: find-issue From 9ad20ee188ec4d6f55b3ae187386009ed58a8f81 Mon Sep 17 00:00:00 2001 From: XDEV Renovate Bot Date: Tue, 22 Oct 2024 02:34:23 +0000 Subject: [PATCH 02/54] Update dependency org.apache.maven.plugins:maven-project-info-reports-plugin to v3.8.0 --- template-placeholder/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template-placeholder/pom.xml b/template-placeholder/pom.xml index fa368399..e963c1b1 100644 --- a/template-placeholder/pom.xml +++ b/template-placeholder/pom.xml @@ -95,7 +95,7 @@ org.apache.maven.plugins maven-project-info-reports-plugin - 3.7.0 + 3.8.0 From 009f795f2baf9ac819c4891d297ae5cc2c78534a Mon Sep 17 00:00:00 2001 From: Alex B <45384811+AB-xdev@users.noreply.github.com> Date: Thu, 24 Oct 2024 14:04:20 +0200 Subject: [PATCH 03/54] Initial commit --- LICENSE | 201 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 201 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..261eeb9e --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. From efcd43e6d935ffb84ea540561128bc5173923517 Mon Sep 17 00:00:00 2001 From: AB Date: Thu, 24 Oct 2024 14:14:33 +0200 Subject: [PATCH 04/54] Init --- .gitattributes | 5 + .github/.lycheeignore | 2 + .github/ISSUE_TEMPLATE/bug_report.yml | 68 +++++ .github/ISSUE_TEMPLATE/config.yml | 4 + .github/ISSUE_TEMPLATE/enhancement.yml | 32 +++ .github/ISSUE_TEMPLATE/question.yml | 31 ++ .github/labels.yml | 38 +++ .github/workflows/broken-links.yml | 45 +++ .github/workflows/sync-labels.yml | 24 ++ .github/workflows/update-from-template.yml | 318 +++++++++++++++++++++ CHANGELOG.md | 0 LICENSE | 2 +- SECURITY.md | 5 + renovate.json5 | 4 + 14 files changed, 577 insertions(+), 1 deletion(-) create mode 100644 .gitattributes create mode 100644 .github/.lycheeignore create mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/ISSUE_TEMPLATE/enhancement.yml create mode 100644 .github/ISSUE_TEMPLATE/question.yml create mode 100644 .github/labels.yml create mode 100644 .github/workflows/broken-links.yml create mode 100644 .github/workflows/sync-labels.yml create mode 100644 .github/workflows/update-from-template.yml create mode 100644 CHANGELOG.md create mode 100644 SECURITY.md create mode 100644 renovate.json5 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..0f9f33e7 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +# Auto detect text files and perform LF normalization +* text=auto + +# Force sh files to have LF +*.sh text eol=lf diff --git a/.github/.lycheeignore b/.github/.lycheeignore new file mode 100644 index 00000000..972ca610 --- /dev/null +++ b/.github/.lycheeignore @@ -0,0 +1,2 @@ +# Ignorefile for broken link check +localhost diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 00000000..68299d5d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,68 @@ +name: 🐞 Bug +description: Create a bug report for something that is broken +labels: [bug] +body: + - type: markdown + attributes: + value: | + Thank you for reporting a bug. + + Please fill in as much information as possible about your bug so that we don't have to play "information ping-pong" and can help you immediately. + + - type: checkboxes + id: checklist + attributes: + label: "Checklist" + options: + - label: "I am able to reproduce the bug with the [latest version](https://github.com/xdev-software/template-placeholder/releases/latest)" + required: true + - label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/template-placeholder/issues) or [closed](https://github.com/xdev-software/template-placeholder/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to." + required: true + - label: "I have taken the time to fill in all the required details. I understand that the bug report will be dismissed otherwise." + required: true + - label: "This issue contains only one bug." + required: true + + - type: input + id: app-version + attributes: + label: Affected version + description: "In which version did you encounter the bug?" + placeholder: "x.x.x" + validations: + required: true + + - type: textarea + id: steps-to-reproduce + attributes: + label: Steps to reproduce the bug + description: | + What did you do for the bug to show up? + + If you can't cause the bug to show up again reliably (and hence don't have a proper set of steps to give us), please still try to give as many details as possible on how you think you encountered the bug. + placeholder: | + 1. Use '...' + 2. Do '...' + validations: + required: true + + - type: textarea + id: expected-behavior + attributes: + label: Expected behavior + description: | + Tell us what you expect to happen. + + - type: textarea + id: actual-behavior + attributes: + label: Actual behavior + description: | + Tell us what happens with the steps given above. + + - type: textarea + id: additional-information + attributes: + label: Additional information + description: | + Any other relevant information you'd like to include diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 00000000..b6fb79b1 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,4 @@ +contact_links: + - name: 💬 Contact support + url: https://xdev.software/en/services/support + about: "If you need support as soon as possible or/and you can't wait for any pull request" diff --git a/.github/ISSUE_TEMPLATE/enhancement.yml b/.github/ISSUE_TEMPLATE/enhancement.yml new file mode 100644 index 00000000..75231293 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/enhancement.yml @@ -0,0 +1,32 @@ +name: ✨ Feature/Enhancement +description: Suggest a new feature or enhancement +labels: [enhancement] +body: + - type: markdown + attributes: + value: | + Thank you for suggesting a new feature/enhancement. + + - type: checkboxes + id: checklist + attributes: + label: "Checklist" + options: + - label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/template-placeholder/issues) or [closed](https://github.com/xdev-software/template-placeholder/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to." + required: true + - label: "I have taken the time to fill in all the required details. I understand that the feature request will be dismissed otherwise." + required: true + - label: "This issue contains only one feature request/enhancement." + required: true + + - type: textarea + id: description + attributes: + label: Description + validations: + required: true + + - type: textarea + id: additional-information + attributes: + label: Additional information diff --git a/.github/ISSUE_TEMPLATE/question.yml b/.github/ISSUE_TEMPLATE/question.yml new file mode 100644 index 00000000..6ecd6ad5 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/question.yml @@ -0,0 +1,31 @@ +name: ❓ Question +description: Ask a question +labels: [question] +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this form! + + - type: checkboxes + id: checklist + attributes: + label: "Checklist" + options: + - label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/template-placeholder/issues) or [closed](https://github.com/xdev-software/template-placeholder/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to." + required: true + - label: "I have taken the time to fill in all the required details. I understand that the question will be dismissed otherwise." + required: true + + - type: textarea + id: what-is-the-question + attributes: + label: What is/are your question(s)? + validations: + required: true + + - type: textarea + id: additional-information + attributes: + label: Additional information + description: "Any other information you'd like to include - for instance logs, screenshots, etc." diff --git a/.github/labels.yml b/.github/labels.yml new file mode 100644 index 00000000..325f4ce8 --- /dev/null +++ b/.github/labels.yml @@ -0,0 +1,38 @@ +# Default +## Required for template +- name: bug + description: "Something isn't working" + color: 'd73a4a' +- name: enhancement + description: New feature or request + color: '#a2eeef' +- name: question + description: Information is requested + color: '#d876e3' +## Others +- name: duplicate + description: This already exists + color: '#cfd3d7' +- name: good first issue + description: Good for newcomers + color: '#7057ff' +- name: help wanted + description: Extra attention is needed + color: '#008672' +- name: invalid + description: "This doesn't seem right" + color: '#e4e669' +# Custom +- name: automated + description: Created by an automation + color: '#000000' +- name: "can't reproduce" + color: '#e95f2c' +- name: customer-requested + description: Was requested by a customer of us + color: '#068374' +- name: stale + color: '#ededed' +- name: waiting-for-response + description: If no response is received after a certain time the issue will be closed + color: '#202020' diff --git a/.github/workflows/broken-links.yml b/.github/workflows/broken-links.yml new file mode 100644 index 00000000..48265e89 --- /dev/null +++ b/.github/workflows/broken-links.yml @@ -0,0 +1,45 @@ +name: Broken links + +on: + workflow_dispatch: + schedule: + - cron: "23 23 * * 0" + +permissions: + issues: write + +jobs: + link-checker: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - run: mv .github/.lycheeignore .lycheeignore + + - name: Link Checker + id: lychee + uses: lycheeverse/lychee-action@v2 + with: + fail: false # Don't fail on broken links, create an issue instead + + - name: Find already existing issue + id: find-issue + run: | + echo "number=$(gh issue list -l 'bug' -l 'automated' -L 1 -S 'in:title \"Link Checker Report\"' -s 'open' --json 'number' --jq '.[].number')" >> $GITHUB_OUTPUT + env: + GH_TOKEN: ${{ github.token }} + + - name: Close issue if everything is fine + if: env.lychee_exit_code == 0 && steps.find-issue.outputs.number != '' + run: gh issue close -r 'not planned' ${{ steps.find-issue.outputs.number }} + env: + GH_TOKEN: ${{ github.token }} + + - name: Create Issue From File + if: env.lychee_exit_code != 0 + uses: peter-evans/create-issue-from-file@v5 + with: + issue-number: ${{ steps.find-issue.outputs.number }} + title: Link Checker Report + content-filepath: ./lychee/out.md + labels: bug, automated diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml new file mode 100644 index 00000000..ff880f07 --- /dev/null +++ b/.github/workflows/sync-labels.yml @@ -0,0 +1,24 @@ +name: Sync labels + +on: + push: + branches: develop + paths: + - .github/labels.yml + + workflow_dispatch: + +permissions: + issues: write + +jobs: + labels: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + sparse-checkout: .github/labels.yml + + - uses: EndBug/label-sync@v2 + with: + config-file: .github/labels.yml diff --git a/.github/workflows/update-from-template.yml b/.github/workflows/update-from-template.yml new file mode 100644 index 00000000..3ad8e88d --- /dev/null +++ b/.github/workflows/update-from-template.yml @@ -0,0 +1,318 @@ +name: Update from Template + +# This workflow keeps the repo up to date with changes from the template repo (REMOTE_URL) +# It duplicates the REMOTE_BRANCH (into UPDATE_BRANCH) and tries to merge it into +# this repos default branch (which is checked out here) +# Note that this requires a PAT (Personal Access Token) - at best from a servicing account +# PAT permissions: read:discussion, read:org, repo, workflow +# Also note that you should have at least once merged the template repo into the current repo manually +# otherwise a "refusing to merge unrelated histories" error might occur. + +on: + schedule: + - cron: '55 2 * * 1' + workflow_dispatch: + inputs: + no_automatic_merge: + type: boolean + description: 'No automatic merge' + default: false + +env: + UPDATE_BRANCH: update-from-template + UPDATE_BRANCH_MERGED: update-from-template-merged + REMOTE_URL: https://github.com/xdev-software/base-template.git + REMOTE_BRANCH: master + +permissions: + contents: write + pull-requests: write + +jobs: + update: + runs-on: ubuntu-latest + outputs: + update_branch_merged_commit: ${{ steps.manage-branches.outputs.update_branch_merged_commit }} + create_update_branch_merged_pr: ${{ steps.manage-branches.outputs.create_update_branch_merged_pr }} + steps: + - uses: actions/checkout@v4 + with: + # Required because otherwise there are always changes detected when executing diff/rev-list + fetch-depth: 0 + # If no PAT is used the following error occurs on a push: + # refusing to allow a GitHub App to create or update workflow `.github/workflows/xxx.yml` without `workflows` permission + token: ${{ secrets.UPDATE_FROM_TEMPLATE_PAT }} + + - name: Init Git + run: | + git config --global user.email "111048771+xdev-gh-bot@users.noreply.github.com" + git config --global user.name "XDEV Bot" + + - name: Manage branches + id: manage-branches + run: | + echo "Adding remote template-repo" + git remote add template ${{ env.REMOTE_URL }} + + echo "Fetching remote template repo" + git fetch template + + echo "Deleting local branches that will contain the updates - if present" + git branch -D ${{ env.UPDATE_BRANCH }} || true + git branch -D ${{ env.UPDATE_BRANCH_MERGED }} || true + + echo "Checking if the remote template repo has new commits" + git rev-list ..template/${{ env.REMOTE_BRANCH }} + + if [ $(git rev-list --count ..template/${{ env.REMOTE_BRANCH }}) -eq 0 ]; then + echo "There are no commits new commits on the template repo" + + echo "Deleting origin branch(es) that contain the updates - if present" + git push -f origin --delete ${{ env.UPDATE_BRANCH }} || true + git push -f origin --delete ${{ env.UPDATE_BRANCH_MERGED }} || true + + echo "create_update_branch_pr=0" >> $GITHUB_OUTPUT + echo "create_update_branch_merged_pr=0" >> $GITHUB_OUTPUT + exit 0 + fi + + echo "Found new commits on the template repo" + + echo "Creating update branch" + git branch ${{ env.UPDATE_BRANCH }} template/${{ env.REMOTE_BRANCH }} + git branch --unset-upstream ${{ env.UPDATE_BRANCH }} + + echo "Pushing update branch" + git push -f -u origin ${{ env.UPDATE_BRANCH }} + + echo "Getting base branch" + base_branch=$(git branch --show-current) + echo "Base branch is $base_branch" + echo "base_branch=$base_branch" >> $GITHUB_OUTPUT + + echo "Trying to create auto-merged branch ${{ env.UPDATE_BRANCH_MERGED }}" + git branch ${{ env.UPDATE_BRANCH_MERGED }} ${{ env.UPDATE_BRANCH }} + git checkout ${{ env.UPDATE_BRANCH_MERGED }} + + echo "Merging branch $base_branch into ${{ env.UPDATE_BRANCH_MERGED }}" + git merge $base_branch && merge_exit_code=$? || merge_exit_code=$? + if [ $merge_exit_code -ne 0 ]; then + echo "Auto merge failed! Manual merge required" + echo "::notice ::Auto merge failed - Manual merge required" + + echo "Cleaning up failed merge" + git merge --abort + git checkout $base_branch + git branch -D ${{ env.UPDATE_BRANCH_MERGED }} || true + + echo "Deleting auto-merge branch - if present" + git push -f origin --delete ${{ env.UPDATE_BRANCH_MERGED }} || true + + echo "create_update_branch_pr=1" >> $GITHUB_OUTPUT + echo "create_update_branch_merged_pr=0" >> $GITHUB_OUTPUT + exit 0 + fi + + echo "Post processing: Trying to automatically fill in template variables" + find . -type f \ + -not -path "./.git/**" \ + -not -path "./.github/workflows/update-from-template.yml" -print0 \ + | xargs -0 sed -i "s/template-placeholder/${GITHUB_REPOSITORY#*/}/g" + + git status + git add --all + + if [[ "$(git status --porcelain)" != "" ]]; then + echo "Filled in template; Committing" + + git commit -m "Fill in template" + fi + + echo "Pushing auto-merged branch" + git push -f -u origin ${{ env.UPDATE_BRANCH_MERGED }} + + echo "update_branch_merged_commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT + + echo "Restoring base branch $base_branch" + git checkout $base_branch + + echo "create_update_branch_pr=0" >> $GITHUB_OUTPUT + echo "create_update_branch_merged_pr=1" >> $GITHUB_OUTPUT + echo "try_close_update_branch_pr=1" >> $GITHUB_OUTPUT + + - name: Create/Update PR update_branch + if: steps.manage-branches.outputs.create_update_branch_pr == 1 + env: + GH_TOKEN: ${{ secrets.UPDATE_FROM_TEMPLATE_PAT }} + run: | + gh_pr_up() { + gh pr create -H "${{ env.UPDATE_BRANCH }}" "$@" || (git checkout "${{ env.UPDATE_BRANCH }}" && gh pr edit "$@") + } + gh_pr_up -B "${{ steps.manage-branches.outputs.base_branch }}" \ + --title "Update from template" \ + --body "An automated PR to sync changes from the template into this repo" + + # Ensure that only a single PR is open (otherwise confusion and spam) + - name: Close PR update_branch + if: steps.manage-branches.outputs.try_close_update_branch_pr == 1 + env: + GH_TOKEN: ${{ secrets.UPDATE_FROM_TEMPLATE_PAT }} + run: | + gh pr close "${{ env.UPDATE_BRANCH }}" || true + + - name: Create/Update PR update_branch_merged + if: steps.manage-branches.outputs.create_update_branch_merged_pr == 1 + env: + GH_TOKEN: ${{ secrets.UPDATE_FROM_TEMPLATE_PAT }} + run: | + gh_pr_up() { + gh pr create -H "${{ env.UPDATE_BRANCH_MERGED }}" "$@" || (git checkout "${{ env.UPDATE_BRANCH_MERGED }}" && gh pr edit "$@") + } + gh_pr_up -B "${{ steps.manage-branches.outputs.base_branch }}" \ + --title "Update from template (auto-merged)" \ + --body "An automated PR to sync changes from the template into this repo" + + # Wait a moment so that checks of PR have higher prio than following job + sleep 3 + + # Split into two jobs to help with executor starvation + auto-merge: + needs: [update] + if: needs.update.outputs.create_update_branch_merged_pr == 1 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + # Required because otherwise there are always changes detected when executing diff/rev-list + fetch-depth: 0 + # If no PAT is used the following error occurs on a push: + # refusing to allow a GitHub App to create or update workflow `.github/workflows/xxx.yml` without `workflows` permission + token: ${{ secrets.UPDATE_FROM_TEMPLATE_PAT }} + + - name: Init Git + run: | + git config --global user.email "111048771+xdev-gh-bot@users.noreply.github.com" + git config --global user.name "XDEV Bot" + + - name: Checking if auto-merge for PR update_branch_merged can be done + id: auto-merge-check + env: + GH_TOKEN: ${{ secrets.UPDATE_FROM_TEMPLATE_PAT }} + run: | + not_failed_conclusion="skipped|neutral|success" + not_relevant_app_slug="dependabot|github-pages|sonarcloud" + + echo "Waiting for checks to start..." + sleep 40s + + for i in {1..20}; do + echo "Checking if PR can be auto-merged. Try: $i" + + echo "Checking if update-branch-merged exists" + git fetch + if [[ $(git rev-parse origin/${{ env.UPDATE_BRANCH_MERGED }}) ]]; then + echo "Branch still exists; Continuing..." + else + echo "Branch origin/${{ env.UPDATE_BRANCH_MERGED }} is missing" + exit 0 + fi + + echo "Fetching checks" + cs_response=$(curl -sL \ + --fail-with-body \ + --connect-timeout 60 \ + --max-time 120 \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer $GH_TOKEN" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/${{ github.repository }}/commits/${{ needs.update.outputs.update_branch_merged_commit }}/check-suites) + + cs_data=$(echo $cs_response | jq '.check_suites[] | { conclusion: .conclusion, slug: .app.slug, check_runs_url: .check_runs_url }') + echo $cs_data + + if [[ -z "$cs_data" ]]; then + echo "No check suite data - Assuming that there are no checks to run" + + echo "perform=1" >> $GITHUB_OUTPUT + exit 0 + fi + + cs_failed=$(echo $cs_data | jq --arg x "$not_failed_conclusion" 'select ((.conclusion == null or (.conclusion | test($x))) | not)') + if [[ -z "$cs_failed" ]]; then + echo "No check failed so far; Checking if relevant checks are still running" + + cs_relevant_still_running=$(echo $cs_data | jq --arg x "$not_relevant_app_slug" 'select (.conclusion == null and (.slug | test($x) | not))') + if [[ -z $cs_relevant_still_running ]]; then + echo "All relevant checks finished - PR can be merged" + + echo "perform=1" >> $GITHUB_OUTPUT + exit 0 + else + echo "Relevant checks are still running" + echo $cs_relevant_still_running + fi + else + echo "Detected failed check" + echo $cs_failed + + echo "perform=0" >> $GITHUB_OUTPUT + exit 0 + fi + + echo "Waiting before next run..." + sleep 30s + done + + echo "Timed out - Assuming executor starvation - Forcing merge" + echo "perform=1" >> $GITHUB_OUTPUT + + - name: Auto-merge update_branch_merged + if: steps.auto-merge-check.outputs.perform == 1 + run: | + echo "Getting base branch" + base_branch=$(git branch --show-current) + echo "Base branch is $base_branch" + + echo "Fetching..." + git fetch + if [[ $(git rev-parse origin/${{ env.UPDATE_BRANCH_MERGED }}) ]]; then + echo "Branch still exists; Continuing..." + else + echo "Branch origin/${{ env.UPDATE_BRANCH_MERGED }} is missing" + exit 0 + fi + + expected_commit="${{ needs.update.outputs.update_branch_merged_commit }}" + actual_commit=$(git rev-parse origin/${{ env.UPDATE_BRANCH_MERGED }}) + if [[ "$expected_commit" != "$actual_commit" ]]; then + echo "Branch ${{ env.UPDATE_BRANCH_MERGED }} contains unexpected commit $actual_commit" + echo "Expected: $expected_commit" + + exit 0 + fi + + echo "Ensuring that current branch $base_branch is up-to-date" + git pull + + echo "Merging origin/${{ env.UPDATE_BRANCH_MERGED }} into $base_branch" + git merge origin/${{ env.UPDATE_BRANCH_MERGED }} && merge_exit_code=$? || merge_exit_code=$? + if [ $merge_exit_code -ne 0 ]; then + echo "Unexpected merge failure $merge_exit_code - Requires manual resolution" + + exit 0 + fi + + if [[ "${{ inputs.no_automatic_merge }}" == "true" ]]; then + echo "Exiting due no_automatic_merge" + + exit 0 + fi + + echo "Pushing" + git push + + echo "Cleaning up" + git branch -D ${{ env.UPDATE_BRANCH }} || true + git branch -D ${{ env.UPDATE_BRANCH_MERGED }} || true + git push -f origin --delete ${{ env.UPDATE_BRANCH }} || true + git push -f origin --delete ${{ env.UPDATE_BRANCH_MERGED }} || true diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..e69de29b diff --git a/LICENSE b/LICENSE index 261eeb9e..ccaa2b3a 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [yyyy] [name of copyright owner] + Copyright 2024 XDEV Software Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000..34b9514d --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,5 @@ +# Security Policy + +## Reporting a Vulnerability + +Please report a security vulnerability [on GitHub Security Advisories](https://github.com/xdev-software/template-placeholder/security/advisories/new). diff --git a/renovate.json5 b/renovate.json5 new file mode 100644 index 00000000..11a77b2a --- /dev/null +++ b/renovate.json5 @@ -0,0 +1,4 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "rebaseWhen": "behind-base-branch" +} From 473ce31f9b4826136dd560129d55c54039760e22 Mon Sep 17 00:00:00 2001 From: XDEV Renovate Bot Date: Sat, 26 Oct 2024 02:32:51 +0000 Subject: [PATCH 05/54] Update dependency org.apache.maven.plugins:maven-checkstyle-plugin to v3.6.0 --- pom.xml | 2 +- template-placeholder/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 035f4751..a0329331 100644 --- a/pom.xml +++ b/pom.xml @@ -40,7 +40,7 @@ org.apache.maven.plugins maven-checkstyle-plugin - 3.5.0 + 3.6.0 com.puppycrawl.tools diff --git a/template-placeholder/pom.xml b/template-placeholder/pom.xml index e963c1b1..e669be06 100644 --- a/template-placeholder/pom.xml +++ b/template-placeholder/pom.xml @@ -242,7 +242,7 @@ org.apache.maven.plugins maven-checkstyle-plugin - 3.5.0 + 3.6.0 com.puppycrawl.tools From f2c6db40b00a1554cae8eacb6eaec25bc8dbd039 Mon Sep 17 00:00:00 2001 From: XDEV Renovate Bot Date: Sat, 26 Oct 2024 02:32:52 +0000 Subject: [PATCH 06/54] Update dependency org.apache.maven.plugins:maven-jxr-plugin to v3.6.0 --- pom.xml | 2 +- template-placeholder/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 035f4751..aa6b8cba 100644 --- a/pom.xml +++ b/pom.xml @@ -99,7 +99,7 @@ org.apache.maven.plugins maven-jxr-plugin - 3.5.0 + 3.6.0 diff --git a/template-placeholder/pom.xml b/template-placeholder/pom.xml index e963c1b1..323c61d5 100644 --- a/template-placeholder/pom.xml +++ b/template-placeholder/pom.xml @@ -301,7 +301,7 @@ org.apache.maven.plugins maven-jxr-plugin - 3.5.0 + 3.6.0 From 216f4650d7cd90671ddb7513de3934300bac3dd4 Mon Sep 17 00:00:00 2001 From: XDEV Renovate Bot Date: Sat, 26 Oct 2024 02:32:54 +0000 Subject: [PATCH 07/54] Update net.sourceforge.pmd to v7.7.0 --- pom.xml | 4 ++-- template-placeholder/pom.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 035f4751..e68ab403 100644 --- a/pom.xml +++ b/pom.xml @@ -82,12 +82,12 @@ net.sourceforge.pmd pmd-core - 7.6.0 + 7.7.0 net.sourceforge.pmd pmd-java - 7.6.0 + 7.7.0 diff --git a/template-placeholder/pom.xml b/template-placeholder/pom.xml index e963c1b1..63c5a416 100644 --- a/template-placeholder/pom.xml +++ b/template-placeholder/pom.xml @@ -284,12 +284,12 @@ net.sourceforge.pmd pmd-core - 7.6.0 + 7.7.0 net.sourceforge.pmd pmd-java - 7.6.0 + 7.7.0 From f798625deb74bec76b0e070dd7c3fd7ecacea34b Mon Sep 17 00:00:00 2001 From: XDEV Renovate Bot Date: Sun, 27 Oct 2024 02:38:11 +0000 Subject: [PATCH 08/54] Update dependency com.puppycrawl.tools:checkstyle to v10.19.0 --- pom.xml | 2 +- template-placeholder/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 035f4751..ae44704b 100644 --- a/pom.xml +++ b/pom.xml @@ -45,7 +45,7 @@ com.puppycrawl.tools checkstyle - 10.18.2 + 10.19.0 diff --git a/template-placeholder/pom.xml b/template-placeholder/pom.xml index e963c1b1..eba8ad3f 100644 --- a/template-placeholder/pom.xml +++ b/template-placeholder/pom.xml @@ -247,7 +247,7 @@ com.puppycrawl.tools checkstyle - 10.18.2 + 10.19.0 From d13b2dee2e89f9270e954d48669fe2f506248e4a Mon Sep 17 00:00:00 2001 From: AB Date: Mon, 28 Oct 2024 15:09:18 +0100 Subject: [PATCH 09/54] Changes for PMD 7.7 --- .config/pmd/ruleset.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.config/pmd/ruleset.xml b/.config/pmd/ruleset.xml index 667f74e5..7a03f17c 100644 --- a/.config/pmd/ruleset.xml +++ b/.config/pmd/ruleset.xml @@ -151,5 +151,12 @@ + + + + + + + From a2d6ebcb76f8c23a6bcf35da8f98d2905f425d3c Mon Sep 17 00:00:00 2001 From: XDEV Renovate Bot Date: Tue, 29 Oct 2024 02:39:53 +0000 Subject: [PATCH 10/54] Update dependency org.apache.maven.plugins:maven-pmd-plugin to v3.26.0 --- pom.xml | 2 +- template-placeholder/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 97e1ff13..a62886a6 100644 --- a/pom.xml +++ b/pom.xml @@ -70,7 +70,7 @@ org.apache.maven.plugins maven-pmd-plugin - 3.25.0 + 3.26.0 true true diff --git a/template-placeholder/pom.xml b/template-placeholder/pom.xml index 62a6b63e..454ddcc8 100644 --- a/template-placeholder/pom.xml +++ b/template-placeholder/pom.xml @@ -272,7 +272,7 @@ org.apache.maven.plugins maven-pmd-plugin - 3.25.0 + 3.26.0 true true From 9e9f2a9ee7866ba0f992e87cb0678ab7c4ebbc7f Mon Sep 17 00:00:00 2001 From: AB Date: Wed, 30 Oct 2024 09:11:40 +0100 Subject: [PATCH 11/54] Tighten timeouts --- .github/workflows/broken-links.yml | 1 + .github/workflows/sync-labels.yml | 1 + .github/workflows/update-from-template.yml | 2 ++ 3 files changed, 4 insertions(+) diff --git a/.github/workflows/broken-links.yml b/.github/workflows/broken-links.yml index 48265e89..8f98f1ad 100644 --- a/.github/workflows/broken-links.yml +++ b/.github/workflows/broken-links.yml @@ -11,6 +11,7 @@ permissions: jobs: link-checker: runs-on: ubuntu-latest + timeout-minutes: 15 steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml index ff880f07..c9d7ec78 100644 --- a/.github/workflows/sync-labels.yml +++ b/.github/workflows/sync-labels.yml @@ -14,6 +14,7 @@ permissions: jobs: labels: runs-on: ubuntu-latest + timeout-minutes: 10 steps: - uses: actions/checkout@v4 with: diff --git a/.github/workflows/update-from-template.yml b/.github/workflows/update-from-template.yml index ba0bf090..cb318451 100644 --- a/.github/workflows/update-from-template.yml +++ b/.github/workflows/update-from-template.yml @@ -31,6 +31,7 @@ permissions: jobs: update: runs-on: ubuntu-latest + timeout-minutes: 60 outputs: update_branch_merged_commit: ${{ steps.manage-branches.outputs.update_branch_merged_commit }} create_update_branch_merged_pr: ${{ steps.manage-branches.outputs.create_update_branch_merged_pr }} @@ -180,6 +181,7 @@ jobs: needs: [update] if: needs.update.outputs.create_update_branch_merged_pr == 1 runs-on: ubuntu-latest + timeout-minutes: 60 steps: - uses: actions/checkout@v4 with: From 02fc7af8377fd12b1d825b378cdd4d0c0a3e3b3d Mon Sep 17 00:00:00 2001 From: AB Date: Wed, 30 Oct 2024 09:13:09 +0100 Subject: [PATCH 12/54] Tighten timeouts --- .github/workflows/check-build.yml | 3 +++ .github/workflows/release.yml | 5 +++++ .github/workflows/sonar.yml | 2 ++ .github/workflows/test-deploy.yml | 1 + 4 files changed, 11 insertions(+) diff --git a/.github/workflows/check-build.yml b/.github/workflows/check-build.yml index 2ac65305..c8966a7b 100644 --- a/.github/workflows/check-build.yml +++ b/.github/workflows/check-build.yml @@ -26,6 +26,7 @@ env: jobs: build: runs-on: ubuntu-latest + timeout-minutes: 30 strategy: matrix: @@ -72,6 +73,7 @@ jobs: checkstyle: runs-on: ubuntu-latest + timeout-minutes: 15 if: ${{ github.event_name != 'pull_request' || !startsWith(github.head_ref, 'renovate/') }} strategy: @@ -94,6 +96,7 @@ jobs: pmd: runs-on: ubuntu-latest + timeout-minutes: 15 if: ${{ github.event_name != 'pull_request' || !startsWith(github.head_ref, 'renovate/') }} strategy: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0bf3805c..236c0f59 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,6 +14,7 @@ permissions: jobs: check-code: runs-on: ubuntu-latest + timeout-minutes: 30 steps: - uses: actions/checkout@v4 @@ -48,6 +49,7 @@ jobs: prepare-release: runs-on: ubuntu-latest needs: [check-code] + timeout-minutes: 10 outputs: upload_url: ${{ steps.create_release.outputs.upload_url }} steps: @@ -109,6 +111,7 @@ jobs: publish-maven: runs-on: ubuntu-latest needs: [prepare-release] + timeout-minutes: 60 steps: - uses: actions/checkout@v4 @@ -140,6 +143,7 @@ jobs: publish-pages: runs-on: ubuntu-latest needs: [prepare-release] + timeout-minutes: 15 steps: - uses: actions/checkout@v4 @@ -169,6 +173,7 @@ jobs: after-release: runs-on: ubuntu-latest needs: [publish-maven] + timeout-minutes: 10 steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/sonar.yml b/.github/workflows/sonar.yml index b38f0d82..df6dbb7e 100644 --- a/.github/workflows/sonar.yml +++ b/.github/workflows/sonar.yml @@ -27,6 +27,7 @@ jobs: token-check: runs-on: ubuntu-latest if: ${{ !(github.event_name == 'pull_request' && startsWith(github.head_ref, 'renovate/')) }} + timeout-minutes: 5 outputs: hasToken: ${{ steps.check-token.outputs.has }} steps: @@ -40,6 +41,7 @@ jobs: runs-on: ubuntu-latest needs: token-check if: ${{ needs.token-check.outputs.hasToken }} + timeout-minutes: 30 steps: - uses: actions/checkout@v4 with: diff --git a/.github/workflows/test-deploy.yml b/.github/workflows/test-deploy.yml index e3ed038b..03f5339e 100644 --- a/.github/workflows/test-deploy.yml +++ b/.github/workflows/test-deploy.yml @@ -9,6 +9,7 @@ env: jobs: publish-maven: runs-on: ubuntu-latest + timeout-minutes: 60 steps: - uses: actions/checkout@v4 From 89a6b057d3436a931931105459f573100590d250 Mon Sep 17 00:00:00 2001 From: AB Date: Wed, 30 Oct 2024 10:30:45 +0100 Subject: [PATCH 13/54] Update check-build.yml --- .github/workflows/check-build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check-build.yml b/.github/workflows/check-build.yml index c8966a7b..08181168 100644 --- a/.github/workflows/check-build.yml +++ b/.github/workflows/check-build.yml @@ -73,8 +73,8 @@ jobs: checkstyle: runs-on: ubuntu-latest - timeout-minutes: 15 if: ${{ github.event_name != 'pull_request' || !startsWith(github.head_ref, 'renovate/') }} + timeout-minutes: 15 strategy: matrix: @@ -96,8 +96,8 @@ jobs: pmd: runs-on: ubuntu-latest - timeout-minutes: 15 if: ${{ github.event_name != 'pull_request' || !startsWith(github.head_ref, 'renovate/') }} + timeout-minutes: 15 strategy: matrix: From 71f1b1dab2fbc93df1efd3870c88ea14f82de9d5 Mon Sep 17 00:00:00 2001 From: XDEV Renovate Bot Date: Fri, 1 Nov 2024 02:39:13 +0000 Subject: [PATCH 14/54] Update dependency com.puppycrawl.tools:checkstyle to v10.20.0 --- pom.xml | 2 +- template-placeholder/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index a62886a6..8e85badb 100644 --- a/pom.xml +++ b/pom.xml @@ -45,7 +45,7 @@ com.puppycrawl.tools checkstyle - 10.19.0 + 10.20.0 diff --git a/template-placeholder/pom.xml b/template-placeholder/pom.xml index 454ddcc8..08cadb5e 100644 --- a/template-placeholder/pom.xml +++ b/template-placeholder/pom.xml @@ -247,7 +247,7 @@ com.puppycrawl.tools checkstyle - 10.19.0 + 10.20.0 From d7b7b8a7dc4f464a641062cd3ff41b9af4394302 Mon Sep 17 00:00:00 2001 From: XDEV Renovate Bot Date: Sun, 3 Nov 2024 02:38:33 +0000 Subject: [PATCH 15/54] Update dependency org.apache.maven.plugins:maven-javadoc-plugin to v3.11.1 --- template-placeholder/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template-placeholder/pom.xml b/template-placeholder/pom.xml index 454ddcc8..e1b6b3c5 100644 --- a/template-placeholder/pom.xml +++ b/template-placeholder/pom.xml @@ -143,7 +143,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.10.1 + 3.11.1 attach-javadocs From d7926e6ce40ec7ee03e218a4eb8433b15d6c1c7e Mon Sep 17 00:00:00 2001 From: XDEV Renovate Bot Date: Fri, 8 Nov 2024 02:32:23 +0000 Subject: [PATCH 16/54] Update dependency com.puppycrawl.tools:checkstyle to v10.20.1 --- pom.xml | 2 +- template-placeholder/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 8e85badb..d069dc67 100644 --- a/pom.xml +++ b/pom.xml @@ -45,7 +45,7 @@ com.puppycrawl.tools checkstyle - 10.20.0 + 10.20.1 diff --git a/template-placeholder/pom.xml b/template-placeholder/pom.xml index e5957151..2155875b 100644 --- a/template-placeholder/pom.xml +++ b/template-placeholder/pom.xml @@ -247,7 +247,7 @@ com.puppycrawl.tools checkstyle - 10.20.0 + 10.20.1 From 8d16f5b86c6eb6a269cddd1fa31671f920a90c94 Mon Sep 17 00:00:00 2001 From: AB Date: Mon, 11 Nov 2024 08:55:26 +0100 Subject: [PATCH 17/54] Update CheckStyle version --- .idea/checkstyle-idea.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.idea/checkstyle-idea.xml b/.idea/checkstyle-idea.xml index eb3fcd83..5f35e018 100644 --- a/.idea/checkstyle-idea.xml +++ b/.idea/checkstyle-idea.xml @@ -1,7 +1,7 @@ - 10.15.0 + 10.20.1 JavaOnlyWithTests true true From d12ec222a2886eae2ba545ce8f58f27e01bb99f8 Mon Sep 17 00:00:00 2001 From: AB Date: Fri, 22 Nov 2024 13:22:07 +0100 Subject: [PATCH 18/54] Generate sources and javadoc during package and not verify This should prevent javadoc problems during release or similar situations --- template-placeholder/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/template-placeholder/pom.xml b/template-placeholder/pom.xml index 2155875b..3a5bc8e9 100644 --- a/template-placeholder/pom.xml +++ b/template-placeholder/pom.xml @@ -147,7 +147,7 @@ attach-javadocs - verify + package jar @@ -165,7 +165,7 @@ attach-sources - verify + package jar-no-fork From 2269c6aa0434f6b2d673e7c1ec5350e41f40d89a Mon Sep 17 00:00:00 2001 From: XDEV Renovate Bot Date: Tue, 26 Nov 2024 02:38:03 +0000 Subject: [PATCH 19/54] Update dependency org.apache.maven.plugins:maven-surefire-plugin to v3.5.2 --- spring-data-eclipse-store-demo/pom.xml | 2 +- spring-data-eclipse-store/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-data-eclipse-store-demo/pom.xml b/spring-data-eclipse-store-demo/pom.xml index 706e7357..6c485e81 100644 --- a/spring-data-eclipse-store-demo/pom.xml +++ b/spring-data-eclipse-store-demo/pom.xml @@ -113,7 +113,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.5.0 + 3.5.2 --add-opens java.base/java.util=ALL-UNNAMED diff --git a/spring-data-eclipse-store/pom.xml b/spring-data-eclipse-store/pom.xml index 273e5569..1a7cd1f7 100644 --- a/spring-data-eclipse-store/pom.xml +++ b/spring-data-eclipse-store/pom.xml @@ -341,7 +341,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.5.0 + 3.5.2 --add-exports java.base/jdk.internal.misc=ALL-UNNAMED From 814e91e25ce6cd49254b739ca3b331b0ddaf1909 Mon Sep 17 00:00:00 2001 From: XDEV Renovate Bot Date: Tue, 26 Nov 2024 02:38:04 +0000 Subject: [PATCH 20/54] Update dependency org.hibernate.orm:hibernate-core to v6.6.3.Final --- spring-data-eclipse-store/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-data-eclipse-store/pom.xml b/spring-data-eclipse-store/pom.xml index 273e5569..81168645 100644 --- a/spring-data-eclipse-store/pom.xml +++ b/spring-data-eclipse-store/pom.xml @@ -57,7 +57,7 @@ 8.0.1.Final 6.0.1 6.0.0-M1 - 6.6.1.Final + 6.6.3.Final From c52cf89caeab1087cb460702e2b5c17f8204452a Mon Sep 17 00:00:00 2001 From: XDEV Renovate Bot Date: Tue, 26 Nov 2024 02:38:05 +0000 Subject: [PATCH 21/54] Update org.springframework.boot.version to v3.4.0 --- spring-data-eclipse-store-benchmark/pom.xml | 2 +- spring-data-eclipse-store-demo/pom.xml | 2 +- spring-data-eclipse-store-jpa/pom.xml | 2 +- spring-data-eclipse-store/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spring-data-eclipse-store-benchmark/pom.xml b/spring-data-eclipse-store-benchmark/pom.xml index 4032e860..5a82fba4 100644 --- a/spring-data-eclipse-store-benchmark/pom.xml +++ b/spring-data-eclipse-store-benchmark/pom.xml @@ -25,7 +25,7 @@ UTF-8 UTF-8 - 3.3.4 + 3.4.0 1.37 diff --git a/spring-data-eclipse-store-demo/pom.xml b/spring-data-eclipse-store-demo/pom.xml index 706e7357..007b4c4d 100644 --- a/spring-data-eclipse-store-demo/pom.xml +++ b/spring-data-eclipse-store-demo/pom.xml @@ -28,7 +28,7 @@ software.xdev.spring.data.eclipse.store.demo.complex.ComplexDemoApplication - 3.3.4 + 3.4.0 diff --git a/spring-data-eclipse-store-jpa/pom.xml b/spring-data-eclipse-store-jpa/pom.xml index 1c8f9a9a..2cd8eb0c 100644 --- a/spring-data-eclipse-store-jpa/pom.xml +++ b/spring-data-eclipse-store-jpa/pom.xml @@ -30,7 +30,7 @@ software.xdev.spring.data.eclipse.store.demo.complex.ComplexDemoApplication - 3.3.4 + 3.4.0 diff --git a/spring-data-eclipse-store/pom.xml b/spring-data-eclipse-store/pom.xml index 273e5569..f0e2cb76 100644 --- a/spring-data-eclipse-store/pom.xml +++ b/spring-data-eclipse-store/pom.xml @@ -51,7 +51,7 @@ UTF-8 - 3.3.4 + 3.4.0 1.4.0 1.4.0 8.0.1.Final From dc00d4c7c9acef401174ca54c2865d8385d67004 Mon Sep 17 00:00:00 2001 From: XDEV Renovate Bot Date: Tue, 26 Nov 2024 02:38:07 +0000 Subject: [PATCH 22/54] Update org.eclipse.store.version to v2 --- spring-data-eclipse-store/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-data-eclipse-store/pom.xml b/spring-data-eclipse-store/pom.xml index 273e5569..f531f571 100644 --- a/spring-data-eclipse-store/pom.xml +++ b/spring-data-eclipse-store/pom.xml @@ -52,7 +52,7 @@ 3.3.4 - 1.4.0 + 2.0.0 1.4.0 8.0.1.Final 6.0.1 From 59b7c022768ff916af92d227f05dd555999a3998 Mon Sep 17 00:00:00 2001 From: XDEV Renovate Bot Date: Sat, 30 Nov 2024 02:36:27 +0000 Subject: [PATCH 23/54] Update net.sourceforge.pmd to v7.8.0 --- pom.xml | 4 ++-- spring-data-eclipse-store/pom.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 0bf3ab25..370445a6 100644 --- a/pom.xml +++ b/pom.xml @@ -93,12 +93,12 @@ net.sourceforge.pmd pmd-core - 7.7.0 + 7.8.0 net.sourceforge.pmd pmd-java - 7.7.0 + 7.8.0 diff --git a/spring-data-eclipse-store/pom.xml b/spring-data-eclipse-store/pom.xml index 273e5569..d858455a 100644 --- a/spring-data-eclipse-store/pom.xml +++ b/spring-data-eclipse-store/pom.xml @@ -482,12 +482,12 @@ net.sourceforge.pmd pmd-core - 7.7.0 + 7.8.0 net.sourceforge.pmd pmd-java - 7.7.0 + 7.8.0 From 2ec98d3be8a62afc571859f21eb96015ac636bc2 Mon Sep 17 00:00:00 2001 From: XDEV Renovate Bot Date: Sat, 30 Nov 2024 02:36:45 +0000 Subject: [PATCH 24/54] Update net.sourceforge.pmd to v7.8.0 --- pom.xml | 4 ++-- template-placeholder/pom.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index d069dc67..0c03cd51 100644 --- a/pom.xml +++ b/pom.xml @@ -82,12 +82,12 @@ net.sourceforge.pmd pmd-core - 7.7.0 + 7.8.0 net.sourceforge.pmd pmd-java - 7.7.0 + 7.8.0 diff --git a/template-placeholder/pom.xml b/template-placeholder/pom.xml index 3a5bc8e9..2269f3f6 100644 --- a/template-placeholder/pom.xml +++ b/template-placeholder/pom.xml @@ -284,12 +284,12 @@ net.sourceforge.pmd pmd-core - 7.7.0 + 7.8.0 net.sourceforge.pmd pmd-java - 7.7.0 + 7.8.0 From a7a9b58ee683a4ca25d134ed22e98735453d8b86 Mon Sep 17 00:00:00 2001 From: XDEV Renovate Bot Date: Sun, 1 Dec 2024 02:46:27 +0000 Subject: [PATCH 25/54] Update dependency com.puppycrawl.tools:checkstyle to v10.20.2 --- pom.xml | 2 +- spring-data-eclipse-store/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 0bf3ab25..07d1bd65 100644 --- a/pom.xml +++ b/pom.xml @@ -50,7 +50,7 @@ com.puppycrawl.tools checkstyle - 10.20.1 + 10.20.2 diff --git a/spring-data-eclipse-store/pom.xml b/spring-data-eclipse-store/pom.xml index 273e5569..7b0a19d4 100644 --- a/spring-data-eclipse-store/pom.xml +++ b/spring-data-eclipse-store/pom.xml @@ -440,7 +440,7 @@ com.puppycrawl.tools checkstyle - 10.20.1 + 10.20.2 From 6b853f13e48fc5e15d102f56523929a7f1ffd22a Mon Sep 17 00:00:00 2001 From: XDEV Renovate Bot Date: Sun, 1 Dec 2024 02:47:14 +0000 Subject: [PATCH 26/54] Update dependency com.puppycrawl.tools:checkstyle to v10.20.2 --- pom.xml | 2 +- template-placeholder/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index d069dc67..5068c8f5 100644 --- a/pom.xml +++ b/pom.xml @@ -45,7 +45,7 @@ com.puppycrawl.tools checkstyle - 10.20.1 + 10.20.2 diff --git a/template-placeholder/pom.xml b/template-placeholder/pom.xml index 3a5bc8e9..8a9db791 100644 --- a/template-placeholder/pom.xml +++ b/template-placeholder/pom.xml @@ -247,7 +247,7 @@ com.puppycrawl.tools checkstyle - 10.20.1 + 10.20.2 From 96f2cb8c50a4504fdb14c323bed9ad4fe34faa6b Mon Sep 17 00:00:00 2001 From: JohannesRabauer Date: Mon, 2 Dec 2024 15:22:42 +0100 Subject: [PATCH 27/54] Update to v2.4.0 --- CHANGELOG.md | 4 ++++ README.md | 3 ++- docs/antora.yml | 6 +++--- pom.xml | 2 +- spring-data-eclipse-store-benchmark/pom.xml | 4 ++-- spring-data-eclipse-store-demo/pom.xml | 4 ++-- spring-data-eclipse-store-jpa/pom.xml | 4 ++-- spring-data-eclipse-store/pom.xml | 2 +- 8 files changed, 17 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 95b2e41f..e3bb486a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 2.4.0 + +* Updated org.springframework.boot.version to v3.4.0 + # 2.3.1 * Auto-Fix problems with adding ids to entities with existing data store. diff --git a/README.md b/README.md index 5cdd4105..8cc4f127 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,8 @@ instructions** are in the documentation](https://xdev-software.github.io/spring- | ``1.0.5-1.0.7`` | ``17`` | ``3.2.5`` | ``1.3.2`` | | ``1.0.8-1.0.10`` | ``17`` | ``3.3.1`` | ``1.3.2`` | | ``2.0.0-2.1.0`` | ``17`` | ``3.3.2`` | ``1.4.0`` | -| ``>= 2.2.0`` | ``17`` | ``3.3.4`` | ``1.4.0`` | +| ``2.2.0-2.3.1`` | ``17`` | ``3.3.4`` | ``1.4.0`` | +| ``>= 2.4.0`` | ``17`` | ``3.4.0`` | ``1.4.0`` | ## Demo diff --git a/docs/antora.yml b/docs/antora.yml index 4875528b..56709584 100644 --- a/docs/antora.yml +++ b/docs/antora.yml @@ -1,14 +1,14 @@ name: ROOT title: Spring-Data-Eclipse-Store version: master -display_version: '2.3.1' +display_version: '2.4.0' start_page: index.adoc nav: - modules/ROOT/nav.adoc asciidoc: attributes: product-name: 'Spring-Data-Eclipse-Store' - display-version: '2.3.1' - maven-version: '2.3.1' + display-version: '2.4.0' + maven-version: '2.4.0' page-editable: false page-out-of-support: false diff --git a/pom.xml b/pom.xml index 4f949cc3..a9c27307 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ software.xdev spring-data-eclipse-store-root - 2.3.2-SNAPSHOT + 2.4.0-SNAPSHOT pom diff --git a/spring-data-eclipse-store-benchmark/pom.xml b/spring-data-eclipse-store-benchmark/pom.xml index 5a82fba4..e9a4cc1f 100644 --- a/spring-data-eclipse-store-benchmark/pom.xml +++ b/spring-data-eclipse-store-benchmark/pom.xml @@ -5,11 +5,11 @@ software.xdev spring-data-eclipse-store-root - 2.3.2-SNAPSHOT + 2.4.0-SNAPSHOT spring-data-eclipse-store-benchmark - 2.3.2-SNAPSHOT + 2.4.0-SNAPSHOT jar 2023 diff --git a/spring-data-eclipse-store-demo/pom.xml b/spring-data-eclipse-store-demo/pom.xml index a4a17b9d..b36c5664 100644 --- a/spring-data-eclipse-store-demo/pom.xml +++ b/spring-data-eclipse-store-demo/pom.xml @@ -7,11 +7,11 @@ software.xdev spring-data-eclipse-store-root - 2.3.2-SNAPSHOT + 2.4.0-SNAPSHOT spring-data-eclipse-store-demo - 2.3.2-SNAPSHOT + 2.4.0-SNAPSHOT jar diff --git a/spring-data-eclipse-store-jpa/pom.xml b/spring-data-eclipse-store-jpa/pom.xml index 2cd8eb0c..d06dacf3 100644 --- a/spring-data-eclipse-store-jpa/pom.xml +++ b/spring-data-eclipse-store-jpa/pom.xml @@ -7,11 +7,11 @@ software.xdev spring-data-eclipse-store-root - 2.3.2-SNAPSHOT + 2.4.0-SNAPSHOT spring-data-eclipse-store-jpa - 2.3.2-SNAPSHOT + 2.4.0-SNAPSHOT jar 2023 diff --git a/spring-data-eclipse-store/pom.xml b/spring-data-eclipse-store/pom.xml index b3a4646e..5a7b501d 100644 --- a/spring-data-eclipse-store/pom.xml +++ b/spring-data-eclipse-store/pom.xml @@ -6,7 +6,7 @@ software.xdev spring-data-eclipse-store - 2.3.2-SNAPSHOT + 2.4.0-SNAPSHOT jar spring-data-eclipse-store From 2705b95b2d160d71d086571f72e84ce6cb403faf Mon Sep 17 00:00:00 2001 From: JohannesRabauer Date: Mon, 2 Dec 2024 15:37:17 +0100 Subject: [PATCH 28/54] Update SpringDataEclipseStoreLazy.java --- .../lazy/SpringDataEclipseStoreLazy.java | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/lazy/SpringDataEclipseStoreLazy.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/lazy/SpringDataEclipseStoreLazy.java index 2d29d410..984540bf 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/lazy/SpringDataEclipseStoreLazy.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/lazy/SpringDataEclipseStoreLazy.java @@ -17,7 +17,10 @@ import java.lang.reflect.Field; import java.util.Objects; +import java.util.function.Consumer; +import org.eclipse.serializer.collections.HashEnum; +import org.eclipse.serializer.collections.types.XGettingEnum; import org.eclipse.serializer.reference.Lazy; import org.eclipse.serializer.reference.ObjectSwizzling; import org.eclipse.serializer.reference.Swizzling; @@ -73,6 +76,7 @@ final class Default implements SpringDataEclipseStoreLazy private transient ObjectSwizzling loader; private transient WorkingCopier copier; private transient boolean isStored; + private final transient HashEnum usageMarks = HashEnum.New(); private Default(final Lazy lazySubject) { @@ -259,5 +263,65 @@ public boolean isOriginalObject() { return this.objectToBeWrapped != null; } + + // region Copied from org.eclipse.serializer.reference.UsageMarkable#Default + @Override + public int markUsedFor(final Object instance) + { + // lock internal instance to avoid side effect deadlocks + synchronized(this.usageMarks) + { + final boolean added = this.usageMarks.add(instance); + + return this.usageMarks.intSize() * (added ? 1 : -1); + } + } + + @Override + public int unmarkUsedFor(final Object instance) + { + // lock internal instance to avoid side effect deadlocks + synchronized(this.usageMarks) + { + final boolean removed = this.usageMarks.removeOne(instance); + + return this.usageMarks.intSize() * (removed ? 1 : -1); + } + } + + @Override + public boolean isUsed() + { + // lock internal instance to avoid side effect deadlocks + synchronized(this.usageMarks) + { + return !this.usageMarks.isEmpty(); + } + } + + @Override + public int markUnused() + { + // lock internal instance to avoid side effect deadlocks + synchronized(this.usageMarks) + { + final int currentSize = this.usageMarks.intSize(); + this.usageMarks.clear(); + + return currentSize; + } + } + + @Override + public void accessUsageMarks(final Consumer> logic) + { + // lock internal instance to avoid side effect deadlocks + synchronized(this.usageMarks) + { + // no null check to give logic a chance to notice no-marks case. + logic.accept(this.usageMarks); + } + } + // endregion } } From 193eb04544fb2d784504d08ec22995765ddf7bb5 Mon Sep 17 00:00:00 2001 From: JohannesRabauer Date: Mon, 2 Dec 2024 15:44:28 +0100 Subject: [PATCH 29/54] Update Eclipse serializer --- spring-data-eclipse-store/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-data-eclipse-store/pom.xml b/spring-data-eclipse-store/pom.xml index cbfb25de..1b86cd82 100644 --- a/spring-data-eclipse-store/pom.xml +++ b/spring-data-eclipse-store/pom.xml @@ -53,7 +53,7 @@ 3.4.0 2.0.0 - 1.4.0 + 2.0.0 8.0.1.Final 6.0.1 6.0.0-M1 From 4de3869a78d0de7c007f14c6519e3070f7ef1d7b Mon Sep 17 00:00:00 2001 From: JohannesRabauer Date: Tue, 3 Dec 2024 06:54:45 +0100 Subject: [PATCH 30/54] Fix PMD issue --- .../store/repository/lazy/SpringDataEclipseStoreLazy.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/lazy/SpringDataEclipseStoreLazy.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/lazy/SpringDataEclipseStoreLazy.java index 984540bf..182d2990 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/lazy/SpringDataEclipseStoreLazy.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/lazy/SpringDataEclipseStoreLazy.java @@ -17,6 +17,7 @@ import java.lang.reflect.Field; import java.util.Objects; +import java.util.concurrent.locks.ReentrantLock; import java.util.function.Consumer; import org.eclipse.serializer.collections.HashEnum; @@ -67,7 +68,7 @@ static SpringDataEclipseStoreLazy.Default buildWithLazy(final Lazy laz * * @param the type of the lazily referenced element */ - @SuppressWarnings({"java:S2065"}) + @SuppressWarnings({"java:S2065", "PMD.AvoidSynchronizedStatement"}) final class Default implements SpringDataEclipseStoreLazy { private T objectToBeWrapped; @@ -76,6 +77,7 @@ final class Default implements SpringDataEclipseStoreLazy private transient ObjectSwizzling loader; private transient WorkingCopier copier; private transient boolean isStored; + private final transient ReentrantLock usageMarksLock = new ReentrantLock(); private final transient HashEnum usageMarks = HashEnum.New(); private Default(final Lazy lazySubject) From b4fb446cb61428113927f8334245d60d429d5e7b Mon Sep 17 00:00:00 2001 From: JohannesRabauer Date: Tue, 3 Dec 2024 07:00:29 +0100 Subject: [PATCH 31/54] Updated README --- CHANGELOG.md | 1 + README.md | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e3bb486a..171ab3c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # 2.4.0 * Updated org.springframework.boot.version to v3.4.0 +* Updated EclipseStore to v2.0.0 # 2.3.1 diff --git a/README.md b/README.md index 8cc4f127..e763ae1a 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ instructions** are in the documentation](https://xdev-software.github.io/spring- | ``1.0.8-1.0.10`` | ``17`` | ``3.3.1`` | ``1.3.2`` | | ``2.0.0-2.1.0`` | ``17`` | ``3.3.2`` | ``1.4.0`` | | ``2.2.0-2.3.1`` | ``17`` | ``3.3.4`` | ``1.4.0`` | -| ``>= 2.4.0`` | ``17`` | ``3.4.0`` | ``1.4.0`` | +| ``>= 2.4.0`` | ``17`` | ``3.4.0`` | ``2.0.0`` | ## Demo From 69f16ef4d4474f9d6ba8525e881c120f483379b6 Mon Sep 17 00:00:00 2001 From: JohannesRabauer Date: Tue, 3 Dec 2024 07:42:43 +0100 Subject: [PATCH 32/54] LazyRepositories: first test with simple lazy wrapper --- .../isolated/tests/lazy/LazyTest.java | 36 ++++++++++++ .../tests/lazy/SimpleEntityWithId.java | 55 +++++++++++++++++++ .../SimpleEntityWithIdLazyRepository.java | 24 ++++++++ 3 files changed, 115 insertions(+) create mode 100644 spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/SimpleEntityWithId.java create mode 100644 spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/SimpleEntityWithIdLazyRepository.java diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/LazyTest.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/LazyTest.java index f2b4d490..d9f2a662 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/LazyTest.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/LazyTest.java @@ -37,6 +37,7 @@ import software.xdev.spring.data.eclipse.store.repository.lazy.SpringDataEclipseStoreLazy; +@SuppressWarnings("checkstyle:MethodName") @IsolatedTestAnnotations @ContextConfiguration(classes = {LazyTestConfiguration.class}) class LazyTest @@ -457,4 +458,39 @@ void lazyChangeAfterRestart(@Autowired final ObjectWithLazyRepository lazyObject = + SpringDataEclipseStoreLazy.build(objectToStore); + repository.save(lazyObject); + + TestUtil.doBeforeAndAfterRestartOfDatastore( + this.configuration, + () -> { + Assertions.assertEquals(1, repository.findAll().size()); + final Lazy reloadedObject = repository.findAll().get(0); + Assertions.assertEquals(objectToStore, reloadedObject.get()); + } + ); + } + + @Test + void simpleEntityWithIdLazyRepository_OnlyLoadOnDemand(@Autowired final SimpleEntityWithIdLazyRepository repository) + { + final SimpleEntityWithId objectToStore = new SimpleEntityWithId(TestData.DUMMY_STRING); + final SpringDataEclipseStoreLazy.Default lazyObject = + SpringDataEclipseStoreLazy.build(objectToStore); + repository.save(lazyObject); + + restartDatastore(this.configuration); + + final Lazy reloadedObject = repository.findAll().get(0); + Assertions.assertFalse(reloadedObject.isLoaded()); + Assertions.assertEquals(objectToStore, reloadedObject.get()); + Assertions.assertTrue(reloadedObject.isLoaded()); + } } diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/SimpleEntityWithId.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/SimpleEntityWithId.java new file mode 100644 index 00000000..c122e1a2 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/SimpleEntityWithId.java @@ -0,0 +1,55 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.lazy; + +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; + + +public class SimpleEntityWithId +{ + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + private String name; + + public SimpleEntityWithId(final String name) + { + this.name = name; + } + + public String getName() + { + return this.name; + } + + public void setName(final String name) + { + this.name = name; + } + + public long getId() + { + return this.id; + } + + public void setId(final long id) + { + this.id = id; + } +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/SimpleEntityWithIdLazyRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/SimpleEntityWithIdLazyRepository.java new file mode 100644 index 00000000..2e2ca118 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/SimpleEntityWithIdLazyRepository.java @@ -0,0 +1,24 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.lazy; + +import org.eclipse.serializer.reference.Lazy; +import org.springframework.data.repository.ListCrudRepository; + + +public interface SimpleEntityWithIdLazyRepository extends ListCrudRepository, Long> +{ +} From 00d4907bbdb3fbc5335e5acb2f5132417a6df3e1 Mon Sep 17 00:00:00 2001 From: JohannesRabauer Date: Tue, 3 Dec 2024 11:10:42 +0100 Subject: [PATCH 33/54] LazyRepositories: Added basic LazySimpleEclipseStoreRepository --- spring-data-eclipse-store/pom.xml | 2 + .../store/repository/EclipseStoreStorage.java | 9 +- ...StoreRepositoryConfigurationExtension.java | 14 ++- .../lazy/LazyEclipseStoreCrudRepository.java | 100 ++++++++++++++++++ .../LazyEclipseStoreCustomRepository.java | 27 +++++ .../LazyEclipseStoreListCrudRepository.java | 100 ++++++++++++++++++ ...tPagingAndSortingRepositoryRepository.java | 28 +++++ ...ePagingAndSortingRepositoryRepository.java | 28 +++++ ...azyEclipseStoreQueryByExampleExecutor.java | 27 +++++ .../lazy/LazyEclipseStoreRepository.java | 33 ++++++ .../EclipseStoreQueryLookupStrategy.java | 14 ++- .../EclipseStoreRepositoryFactory.java | 10 +- .../LazySimpleEclipseStoreRepository.java | 80 ++++++++++++++ .../isolated/tests/lazy/LazyTest.java | 44 +++++++- .../SimpleEntityWithIdLazyRepository.java | 5 +- ...mpleEntityWithIdLazyWrappedRepository.java | 24 +++++ 16 files changed, 528 insertions(+), 17 deletions(-) create mode 100644 spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreCrudRepository.java create mode 100644 spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreCustomRepository.java create mode 100644 spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreListCrudRepository.java create mode 100644 spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreListPagingAndSortingRepositoryRepository.java create mode 100644 spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStorePagingAndSortingRepositoryRepository.java create mode 100644 spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreQueryByExampleExecutor.java create mode 100644 spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreRepository.java create mode 100644 spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/LazySimpleEclipseStoreRepository.java create mode 100644 spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/SimpleEntityWithIdLazyWrappedRepository.java diff --git a/spring-data-eclipse-store/pom.xml b/spring-data-eclipse-store/pom.xml index 1b86cd82..201eb90d 100644 --- a/spring-data-eclipse-store/pom.xml +++ b/spring-data-eclipse-store/pom.xml @@ -314,6 +314,8 @@ maven-compiler-plugin 3.13.0 + ${javaVersion} + ${javaVersion} ${maven.compiler.release} -proc:none diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreStorage.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreStorage.java index 4f902583..3cfd0b26 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreStorage.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreStorage.java @@ -38,6 +38,7 @@ import software.xdev.spring.data.eclipse.store.exceptions.InvalidRootException; import software.xdev.spring.data.eclipse.store.repository.config.EclipseStoreClientConfiguration; import software.xdev.spring.data.eclipse.store.repository.config.EclipseStoreStorageFoundationProvider; +import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository; import software.xdev.spring.data.eclipse.store.repository.root.EntityData; import software.xdev.spring.data.eclipse.store.repository.root.VersionedRoot; import software.xdev.spring.data.eclipse.store.repository.support.SimpleEclipseStoreRepository; @@ -58,7 +59,7 @@ public class EclipseStoreStorage implements EntityListProvider, IdManagerProvider, VersionManagerProvider, PersistableChecker, ObjectSwizzling { private static final Logger LOG = LoggerFactory.getLogger(EclipseStoreStorage.class); - private final Map, SimpleEclipseStoreRepository> entityClassToRepository = new HashMap<>(); + private final Map, EclipseStoreRepository> entityClassToRepository = new HashMap<>(); /** * "Why are the IdManagers seperated from the repositories?" - Because there might be entities for which there are * no repositories, but they still have IDs. @@ -155,9 +156,9 @@ else if(!(embeddedStorageManager.root() instanceof VersionedRoot)) return embeddedStorageFoundation; } - public SimpleEclipseStoreRepository getRepository(final Class entityClass) + public EclipseStoreRepository getRepository(final Class entityClass) { - return (SimpleEclipseStoreRepository)this.entityClassToRepository.get(entityClass); + return this.entityClassToRepository.get(entityClass); } private void initRoot() @@ -217,7 +218,7 @@ private void setIdManagerForEntityData(final Class entityClass, final public synchronized void registerEntity( final Class classToRegister, - final SimpleEclipseStoreRepository repository) + final EclipseStoreRepository repository) { if(this.entityClassToRepository.containsKey(classToRegister)) { diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/config/EclipseStoreRepositoryConfigurationExtension.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/config/EclipseStoreRepositoryConfigurationExtension.java index 9c56bed6..4cac26e9 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/config/EclipseStoreRepositoryConfigurationExtension.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/config/EclipseStoreRepositoryConfigurationExtension.java @@ -37,6 +37,12 @@ import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreListPagingAndSortingRepositoryRepository; import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStorePagingAndSortingRepositoryRepository; import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository; +import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreCrudRepository; +import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreCustomRepository; +import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreListCrudRepository; +import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreListPagingAndSortingRepositoryRepository; +import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStorePagingAndSortingRepositoryRepository; +import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreRepository; import software.xdev.spring.data.eclipse.store.repository.support.EclipseStoreRepositoryFactoryBean; @@ -121,7 +127,13 @@ protected Collection> getIdentifyingTypes() EclipseStorePagingAndSortingRepositoryRepository.class, EclipseStoreListPagingAndSortingRepositoryRepository.class, EclipseStoreCrudRepository.class, - EclipseStoreListCrudRepository.class + EclipseStoreListCrudRepository.class, + LazyEclipseStoreRepository.class, + LazyEclipseStoreCustomRepository.class, + LazyEclipseStorePagingAndSortingRepositoryRepository.class, + LazyEclipseStoreListPagingAndSortingRepositoryRepository.class, + LazyEclipseStoreCrudRepository.class, + LazyEclipseStoreListCrudRepository.class ); } diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreCrudRepository.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreCrudRepository.java new file mode 100644 index 00000000..0d4f8df1 --- /dev/null +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreCrudRepository.java @@ -0,0 +1,100 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.repository.interfaces.lazy; + +import org.eclipse.serializer.reference.Lazy; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.NoRepositoryBean; + + +@SuppressWarnings("java:S119") +@NoRepositoryBean +public interface LazyEclipseStoreCrudRepository extends CrudRepository, ID> +{ + /** + * @inheritDoc Caution with referenced objects!
If you are deleting an object that is referenced by + * another object, the behavior of this function may differ from what you are used to! + *

+ * JPA would throw a {@code JdbcSQLIntegrityConstraintViolationException} but it would be very expensive to search + * the referencedObject in the complete object tree and throw the exception. + *

+ * That is why this library simply removes the element from the repository, but if it is still referenced by + * another + * object, this reference is still working and pointing to the object. That means that in fact this the + * object to remove could very well stay in the storage if it is referenced. + *

+ */ + @Override + void deleteById(ID id); + + /** + * @inheritDoc Caution with referenced objects!
If you are deleting an object that is referenced by + * another object, the behavior of this function may differ from what you are used to! + *

+ * For more information see {@link #deleteById(Object)} + *

+ */ + void deleteEntity(T entity); + + /** + * @inheritDoc Caution with referenced objects!
If you are deleting an object that is referenced by + * another object, the behavior of this function may differ from what you are used to! + *

+ * For more information see {@link #deleteById(Object)} + *

+ */ + @Override + void delete(Lazy entity); + + /** + * @inheritDoc Caution with referenced objects!
If you are deleting an object that is referenced by + * another object, the behavior of this function may differ from what you are used to! + *

+ * For more information see {@link #deleteById(Object)} + *

+ */ + @Override + void deleteAllById(Iterable ids); + + /** + * @inheritDoc Caution with referenced objects!
If you are deleting an object that is referenced by + * another object, the behavior of this function may differ from what you are used to! + *

+ * For more information see {@link #deleteById(Object)} + *

+ */ + @Override + void deleteAll(Iterable> entities); + + /** + * @inheritDoc Caution with referenced objects!
If you are deleting an object that is referenced by + * another object, the behavior of this function may differ from what you are used to! + *

+ * For more information see {@link #deleteById(Object)} + *

+ */ + void deleteAllEntities(Iterable entities); + + /** + * @inheritDoc Caution with referenced objects!
If you are deleting an object that is referenced by + * another object, the behavior of this function may differ from what you are used to! + *

+ * For more information see {@link #deleteById(Object)} + *

+ */ + @Override + void deleteAll(); +} diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreCustomRepository.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreCustomRepository.java new file mode 100644 index 00000000..86f55709 --- /dev/null +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreCustomRepository.java @@ -0,0 +1,27 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.repository.interfaces.lazy; + +import org.eclipse.serializer.reference.Lazy; +import org.springframework.data.repository.NoRepositoryBean; +import org.springframework.data.repository.Repository; + + +@SuppressWarnings("java:S119") +@NoRepositoryBean +public interface LazyEclipseStoreCustomRepository extends Repository, ID> +{ +} diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreListCrudRepository.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreListCrudRepository.java new file mode 100644 index 00000000..40983eaa --- /dev/null +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreListCrudRepository.java @@ -0,0 +1,100 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.repository.interfaces.lazy; + +import java.util.List; + +import org.eclipse.serializer.reference.Lazy; +import org.springframework.data.repository.ListCrudRepository; +import org.springframework.data.repository.NoRepositoryBean; + + +@SuppressWarnings("java:S119") +@NoRepositoryBean +public interface LazyEclipseStoreListCrudRepository extends ListCrudRepository, ID> +{ + /** + * @inheritDoc Caution with referenced objects!
If you are deleting an object that is referenced by + * another object, the behavior of this function may differ from what you are used to! + *

+ * For more information see {@link LazyEclipseStoreCrudRepository#deleteById(Object)} + *

+ */ + @Override + void deleteById(ID id); + + /** + * @inheritDoc Caution with referenced objects!
If you are deleting an object that is referenced by + * another object, the behavior of this function may differ from what you are used to! + *

+ * For more information see {@link LazyEclipseStoreCrudRepository#deleteById(Object)} + *

+ */ + @Override + void delete(Lazy entity); + + /** + * @inheritDoc Caution with referenced objects!
If you are deleting an object that is referenced by + * another object, the behavior of this function may differ from what you are used to! + *

+ * For more information see {@link LazyEclipseStoreCrudRepository#deleteById(Object)} + *

+ */ + void deleteEntity(T entity); + + /** + * @inheritDoc Caution with referenced objects!
If you are deleting an object that is referenced by + * another object, the behavior of this function may differ from what you are used to! + *

+ * For more information see {@link LazyEclipseStoreCrudRepository#deleteById(Object)} + *

+ */ + @Override + void deleteAllById(Iterable ids); + + /** + * @inheritDoc Caution with referenced objects!
If you are deleting an object that is referenced by + * another object, the behavior of this function may differ from what you are used to! + *

+ * For more information see {@link LazyEclipseStoreCrudRepository#deleteById(Object)} + *

+ */ + @Override + void deleteAll(Iterable> entities); + + /** + * @inheritDoc Caution with referenced objects!
If you are deleting an object that is referenced by + * another object, the behavior of this function may differ from what you are used to! + *

+ * For more information see {@link LazyEclipseStoreCrudRepository#deleteById(Object)} + *

+ */ + void deleteAllEntities(Iterable entities); + + /** + * @inheritDoc Caution with referenced objects!
If you are deleting an object that is referenced by + * another object, the behavior of this function may differ from what you are used to! + *

+ * For more information see {@link LazyEclipseStoreCrudRepository#deleteById(Object)} + *

+ */ + @Override + void deleteAll(); + + List saveAllEntities(Iterable entities); + + S saveEntity(S entity); +} diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreListPagingAndSortingRepositoryRepository.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreListPagingAndSortingRepositoryRepository.java new file mode 100644 index 00000000..85159e08 --- /dev/null +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreListPagingAndSortingRepositoryRepository.java @@ -0,0 +1,28 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.repository.interfaces.lazy; + +import org.eclipse.serializer.reference.Lazy; +import org.springframework.data.repository.ListPagingAndSortingRepository; +import org.springframework.data.repository.NoRepositoryBean; + + +@SuppressWarnings("java:S119") +@NoRepositoryBean +public interface LazyEclipseStoreListPagingAndSortingRepositoryRepository + extends ListPagingAndSortingRepository, ID> +{ +} diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStorePagingAndSortingRepositoryRepository.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStorePagingAndSortingRepositoryRepository.java new file mode 100644 index 00000000..0aa17954 --- /dev/null +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStorePagingAndSortingRepositoryRepository.java @@ -0,0 +1,28 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.repository.interfaces.lazy; + +import org.eclipse.serializer.reference.Lazy; +import org.springframework.data.repository.NoRepositoryBean; +import org.springframework.data.repository.PagingAndSortingRepository; + + +@SuppressWarnings("java:S119") +@NoRepositoryBean +public interface LazyEclipseStorePagingAndSortingRepositoryRepository + extends PagingAndSortingRepository, ID> +{ +} diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreQueryByExampleExecutor.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreQueryByExampleExecutor.java new file mode 100644 index 00000000..2fb56b8e --- /dev/null +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreQueryByExampleExecutor.java @@ -0,0 +1,27 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.repository.interfaces.lazy; + +import org.eclipse.serializer.reference.Lazy; +import org.springframework.data.repository.NoRepositoryBean; +import org.springframework.data.repository.query.QueryByExampleExecutor; + + +@SuppressWarnings("java:S119") +@NoRepositoryBean +public interface LazyEclipseStoreQueryByExampleExecutor extends QueryByExampleExecutor> +{ +} diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreRepository.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreRepository.java new file mode 100644 index 00000000..00b23ff8 --- /dev/null +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreRepository.java @@ -0,0 +1,33 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.repository.interfaces.lazy; + +import org.springframework.data.repository.NoRepositoryBean; +import org.eclipse.serializer.reference.Lazy; + +import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository; + + +@SuppressWarnings("java:S119") +@NoRepositoryBean +public interface LazyEclipseStoreRepository + extends + LazyEclipseStoreListCrudRepository, + LazyEclipseStoreListPagingAndSortingRepositoryRepository, + LazyEclipseStoreQueryByExampleExecutor, + EclipseStoreRepository, ID> +{ +} diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/EclipseStoreQueryLookupStrategy.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/EclipseStoreQueryLookupStrategy.java index 2f132717..0d355883 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/EclipseStoreQueryLookupStrategy.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/EclipseStoreQueryLookupStrategy.java @@ -19,6 +19,7 @@ import jakarta.annotation.Nonnull; +import org.eclipse.serializer.reference.Lazy; import org.springframework.data.projection.ProjectionFactory; import org.springframework.data.repository.core.NamedQueries; import org.springframework.data.repository.core.RepositoryMetadata; @@ -57,6 +58,12 @@ public RepositoryQuery resolveQuery( { final QueryMethod queryMethod = new QueryMethod(method, metadata, factory); + Class domainType = metadata.getDomainType(); + if(domainType.equals(Lazy.class)) + { + domainType = metadata.getDomainTypeInformation().getTypeArguments().get(0).getType(); + } + final Query queryAnnotation = method.getAnnotation(Query.class); if(queryAnnotation != null) { @@ -64,7 +71,7 @@ public RepositoryQuery resolveQuery( { // Special case for Queries that have findAll and are annotated with Query return this.createFindAllEclipseStoreQueryProvider( - metadata.getDomainType(), + domainType, queryMethod, method ); @@ -72,13 +79,12 @@ public RepositoryQuery resolveQuery( return this.createHSqlQueryProvider( queryAnnotation.value(), - metadata.getDomainType(), + domainType, queryMethod ); } - return this.createStringBasedEclipseStoreQueryProvider( - metadata.getDomainType(), + domainType, queryMethod, method ); diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/EclipseStoreRepositoryFactory.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/EclipseStoreRepositoryFactory.java index 6e28a249..36581fe9 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/EclipseStoreRepositoryFactory.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/EclipseStoreRepositoryFactory.java @@ -20,6 +20,7 @@ import jakarta.annotation.Nonnull; import jakarta.validation.Validator; +import org.eclipse.serializer.reference.Lazy; import org.springframework.data.mapping.model.BasicPersistentEntity; import org.springframework.data.repository.core.EntityInformation; import org.springframework.data.repository.core.RepositoryInformation; @@ -35,6 +36,7 @@ import software.xdev.spring.data.eclipse.store.repository.EclipseStoreStorage; import software.xdev.spring.data.eclipse.store.repository.SupportedChecker; +import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository; import software.xdev.spring.data.eclipse.store.repository.support.copier.working.RecursiveWorkingCopier; import software.xdev.spring.data.eclipse.store.repository.support.copier.working.WorkingCopier; @@ -96,8 +98,7 @@ private WorkingCopier createWorkingCopier( @Nonnull protected Object getTargetRepository(@Nonnull final RepositoryInformation metadata) { - final SimpleEclipseStoreRepository existingRepository = - this.storage.getRepository(metadata.getDomainType()); + final EclipseStoreRepository existingRepository = this.storage.getRepository(metadata.getDomainType()); if(existingRepository != null) { return existingRepository; @@ -117,6 +118,11 @@ protected Object getTargetRepository(@Nonnull final RepositoryInformation metada @Nonnull protected Class getRepositoryBaseClass(@Nonnull final RepositoryMetadata metadata) { + final Class domainType = metadata.getDomainType(); + if(domainType.equals(Lazy.class)) + { + return LazySimpleEclipseStoreRepository.class; + } return SimpleEclipseStoreRepository.class; } diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/LazySimpleEclipseStoreRepository.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/LazySimpleEclipseStoreRepository.java new file mode 100644 index 00000000..05510b04 --- /dev/null +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/LazySimpleEclipseStoreRepository.java @@ -0,0 +1,80 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.repository.support; + +import java.util.List; + +import org.eclipse.serializer.reference.Lazy; + +import software.xdev.spring.data.eclipse.store.repository.EclipseStoreStorage; +import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreCrudRepository; +import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreListCrudRepository; +import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreListPagingAndSortingRepositoryRepository; +import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStorePagingAndSortingRepositoryRepository; +import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreQueryByExampleExecutor; +import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreRepository; +import software.xdev.spring.data.eclipse.store.repository.support.copier.working.WorkingCopier; +import software.xdev.spring.data.eclipse.store.repository.support.id.IdManager; +import software.xdev.spring.data.eclipse.store.transactions.EclipseStoreTransactionManager; + + +@SuppressWarnings("java:S119") +public class LazySimpleEclipseStoreRepository + extends SimpleEclipseStoreRepository, ID> + implements + LazyEclipseStoreRepository, + LazyEclipseStorePagingAndSortingRepositoryRepository, + LazyEclipseStoreListPagingAndSortingRepositoryRepository, + LazyEclipseStoreCrudRepository, + LazyEclipseStoreListCrudRepository, + LazyEclipseStoreQueryByExampleExecutor +{ + + public LazySimpleEclipseStoreRepository( + final EclipseStoreStorage storage, + final WorkingCopier> copier, + final Class> domainClass, + final EclipseStoreTransactionManager transactionManager, + final IdManager, ID> idManager + ) + { + super(storage, copier, domainClass, transactionManager, idManager); + } + + @Override + public void deleteEntity(final T entity) + { + + } + + @Override + public void deleteAllEntities(final Iterable entities) + { + + } + + @Override + public List saveAllEntities(final Iterable entities) + { + return List.of(); + } + + @Override + public S saveEntity(final S entity) + { + return null; + } +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/LazyTest.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/LazyTest.java index d9f2a662..fd1106dc 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/LazyTest.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/LazyTest.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Optional; import org.eclipse.serializer.collections.lazy.LazyArrayList; import org.eclipse.serializer.collections.lazy.LazyList; @@ -31,6 +32,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; +import software.xdev.spring.data.eclipse.store.exceptions.NoIdFieldFoundException; import software.xdev.spring.data.eclipse.store.helper.TestData; import software.xdev.spring.data.eclipse.store.helper.TestUtil; import software.xdev.spring.data.eclipse.store.integration.isolated.IsolatedTestAnnotations; @@ -460,8 +462,8 @@ void lazyChangeAfterRestart(@Autowired final ObjectWithLazyRepository lazyObject = @@ -479,7 +481,8 @@ void simpleEntityWithIdLazyRepository_PersistetAfterRestart( } @Test - void simpleEntityWithIdLazyRepository_OnlyLoadOnDemand(@Autowired final SimpleEntityWithIdLazyRepository repository) + void simpleEntityWithIdLazyWrappedRepository_OnlyLoadOnDemand( + @Autowired final SimpleEntityWithIdLazyWrappedRepository repository) { final SimpleEntityWithId objectToStore = new SimpleEntityWithId(TestData.DUMMY_STRING); final SpringDataEclipseStoreLazy.Default lazyObject = @@ -493,4 +496,39 @@ void simpleEntityWithIdLazyRepository_OnlyLoadOnDemand(@Autowired final SimpleEn Assertions.assertEquals(objectToStore, reloadedObject.get()); Assertions.assertTrue(reloadedObject.isLoaded()); } + + @Test + void simpleEntityWithIdLazyWrappedRepository_FindById( + @Autowired final SimpleEntityWithIdLazyWrappedRepository repository) + { + final SimpleEntityWithId objectToStore1 = new SimpleEntityWithId(TestData.DUMMY_STRING); + repository.save(SpringDataEclipseStoreLazy.build(objectToStore1)); + + final List> all = repository.findAll(); + + Assertions.assertThrows(NoIdFieldFoundException.class, () -> repository.findById(all.get(0).get().getId())); + } + + @Test + void simpleEntityWithIdLazyRepository_FindById(@Autowired final SimpleEntityWithIdLazyRepository repository) + { + final SimpleEntityWithId objectToStore1 = new SimpleEntityWithId(TestData.DUMMY_STRING); + repository.save(SpringDataEclipseStoreLazy.build(objectToStore1)); + final SimpleEntityWithId objectToStore2 = new SimpleEntityWithId(TestData.DUMMY_STRING); + repository.save(SpringDataEclipseStoreLazy.build(objectToStore2)); + + final List> all = repository.findAll(); + + TestUtil.doBeforeAndAfterRestartOfDatastore( + this.configuration, + () -> { + final Optional> reloadedObject = + repository.findById(all.get(0).get().getId()); + Assertions.assertTrue(reloadedObject.isPresent()); + Assertions.assertFalse(reloadedObject.get().isLoaded()); + Assertions.assertEquals(objectToStore1, reloadedObject.get().get()); + Assertions.assertTrue(reloadedObject.get().isLoaded()); + } + ); + } } diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/SimpleEntityWithIdLazyRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/SimpleEntityWithIdLazyRepository.java index 2e2ca118..78a0d6e3 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/SimpleEntityWithIdLazyRepository.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/SimpleEntityWithIdLazyRepository.java @@ -15,10 +15,9 @@ */ package software.xdev.spring.data.eclipse.store.integration.isolated.tests.lazy; -import org.eclipse.serializer.reference.Lazy; -import org.springframework.data.repository.ListCrudRepository; +import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreRepository; -public interface SimpleEntityWithIdLazyRepository extends ListCrudRepository, Long> +public interface SimpleEntityWithIdLazyRepository extends LazyEclipseStoreRepository { } diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/SimpleEntityWithIdLazyWrappedRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/SimpleEntityWithIdLazyWrappedRepository.java new file mode 100644 index 00000000..8331f826 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/SimpleEntityWithIdLazyWrappedRepository.java @@ -0,0 +1,24 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.lazy; + +import org.eclipse.serializer.reference.Lazy; +import org.springframework.data.repository.ListCrudRepository; + + +public interface SimpleEntityWithIdLazyWrappedRepository extends ListCrudRepository, Long> +{ +} From 10c285c5d1aefa1ec21933eac90a23d610cb360f Mon Sep 17 00:00:00 2001 From: JohannesRabauer Date: Tue, 3 Dec 2024 15:25:02 +0100 Subject: [PATCH 34/54] LazyRepositories: Implemented StorageCommunicator --- .../store/repository/EclipseStoreStorage.java | 64 +++++++-- .../store/repository/StorageCommunicator.java | 24 ++++ .../lazy/LazyEclipseStoreCrudRepository.java | 25 +--- .../LazyEclipseStoreCustomRepository.java | 2 +- .../LazyEclipseStoreListCrudRepository.java | 41 +----- ...tPagingAndSortingRepositoryRepository.java | 2 +- ...ePagingAndSortingRepositoryRepository.java | 2 +- ...azyEclipseStoreQueryByExampleExecutor.java | 2 +- .../lazy/LazyEclipseStoreRepository.java | 2 +- .../EclipseStoreFetchableFluentQuery.java | 6 +- .../store/repository/root/EntityData.java | 4 + .../store/repository/root/RootDataV2.java | 2 +- .../store/repository/root/VersionedRoot.java | 17 ++- .../update/scripts/v2_4_0_InitializeLazy.java | 74 ++++++++++ .../repository/root/v2_4/EntityData.java | 54 +++++++ .../repository/root/v2_4/RootDataV2_4.java | 115 +++++++++++++++ .../EclipseStoreRepositoryFactory.java | 10 +- .../LazySimpleEclipseStoreRepository.java | 132 ++++++++++++++++-- .../support/SimpleEclipseStoreRepository.java | 6 +- 19 files changed, 487 insertions(+), 97 deletions(-) create mode 100644 spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/StorageCommunicator.java create mode 100644 spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/update/scripts/v2_4_0_InitializeLazy.java create mode 100644 spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/EntityData.java create mode 100644 spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/RootDataV2_4.java diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreStorage.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreStorage.java index 3cfd0b26..a96f5f79 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreStorage.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreStorage.java @@ -41,7 +41,6 @@ import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository; import software.xdev.spring.data.eclipse.store.repository.root.EntityData; import software.xdev.spring.data.eclipse.store.repository.root.VersionedRoot; -import software.xdev.spring.data.eclipse.store.repository.support.SimpleEclipseStoreRepository; import software.xdev.spring.data.eclipse.store.repository.support.concurrency.ReadWriteLock; import software.xdev.spring.data.eclipse.store.repository.support.concurrency.ReentrantJavaReadWriteLock; import software.xdev.spring.data.eclipse.store.repository.support.copier.version.EntityVersionIncrementer; @@ -60,6 +59,7 @@ public class EclipseStoreStorage { private static final Logger LOG = LoggerFactory.getLogger(EclipseStoreStorage.class); private final Map, EclipseStoreRepository> entityClassToRepository = new HashMap<>(); + private final Map, EclipseStoreRepository> lazyEntityClassToRepository = new HashMap<>(); /** * "Why are the IdManagers seperated from the repositories?" - Because there might be entities for which there are * no repositories, but they still have IDs. @@ -161,6 +161,11 @@ else if(!(embeddedStorageManager.root() instanceof VersionedRoot)) return this.entityClassToRepository.get(entityClass); } + public EclipseStoreRepository getLazyRepository(final Class entityClass) + { + return this.lazyEntityClassToRepository.get(entityClass); + } + private void initRoot() { if(LOG.isDebugEnabled()) @@ -169,6 +174,20 @@ private void initRoot() } this.repositorySynchronizer = new SimpleRepositorySynchronizer(this.root.getCurrentRootData()); + this.ensureEntityData(); + this.ensureLazyEntityData(); + this.entitySetCollector = + new EntitySetCollector( + this.root.getCurrentRootData()::getEntityData, + this.entityClassToRepository.keySet()); + if(LOG.isDebugEnabled()) + { + LOG.debug("Done initializing entity lists."); + } + } + + private void ensureEntityData() + { boolean entityListMustGetStored = false; for(final Class entityClass : this.entityClassToRepository.keySet()) { @@ -186,13 +205,26 @@ private void initRoot() { this.storageManager.store(this.root.getCurrentRootData().getEntityListsToStore()); } - this.entitySetCollector = - new EntitySetCollector( - this.root.getCurrentRootData()::getEntityData, - this.entityClassToRepository.keySet()); - if(LOG.isDebugEnabled()) + } + + private void ensureLazyEntityData() + { + boolean entityListMustGetStored = false; + for(final Class entityClass : this.lazyEntityClassToRepository.keySet()) { - LOG.debug("Done initializing entity lists."); + if(this.root.getCurrentRootData().getLazyEntityData(entityClass) == null) + { + this.createNewLazyEntityData(entityClass, this.root); + entityListMustGetStored = true; + } + else + { + this.setIdManagerForEntityData(entityClass, this.root); + } + } + if(entityListMustGetStored) + { + this.storageManager.store(this.root.getCurrentRootData().getLazyEntityListsToStore()); } } @@ -202,6 +234,12 @@ private void createNewEntityData(final Class entityClass, final Versi root.getCurrentRootData().createNewEntityData(entityClass, idManager::getId); } + private void createNewLazyEntityData(final Class entityClass, final VersionedRoot root) + { + final IdManager idManager = this.ensureIdManager(entityClass); + root.getCurrentRootData().createNewLazyEntityData(entityClass, idManager::getId); + } + private void setIdManagerForEntityData(final Class entityClass, final VersionedRoot root) { final IdManager idManager = this.ensureIdManager(entityClass); @@ -237,9 +275,13 @@ public synchronized void registerEntity( private EntityData getEntityData(final Class clazz) { this.ensureEntitiesInRoot(); - return this.readWriteLock.read( - () -> this.root.getCurrentRootData().getEntityData(clazz) - ); + return this.readWriteLock.read(() -> this.root.getCurrentRootData().getEntityData(clazz)); + } + + private EntityData getLazyEntityData(final Class clazz) + { + this.ensureEntitiesInRoot(); + return this.readWriteLock.read(() -> this.root.getCurrentRootData().getLazyEntityData(clazz)); } @Override @@ -298,10 +340,12 @@ private Collection collectRootEntitiesToStore( final Iterable entitiesToStore) { final EntityData entityData = this.getEntityData(clazz); + final EntityData lazyEntityData = this.getLazyEntityData(clazz); final Collection objectsToStore = new ArrayList<>(); for(final T entityToStore : entitiesToStore) { objectsToStore.addAll(entityData.ensureEntityAndReturnObjectsToStore(entityToStore)); + objectsToStore.addAll(lazyEntityData.ensureEntityAndReturnObjectsToStore(entityToStore)); objectsToStore.add(entityToStore); // Add the separate lists of entities to store. this.repositorySynchronizer.syncAndReturnChangedObjectLists(entityToStore).forEach( diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/StorageCommunicator.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/StorageCommunicator.java new file mode 100644 index 00000000..a11b6f98 --- /dev/null +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/StorageCommunicator.java @@ -0,0 +1,24 @@ +package software.xdev.spring.data.eclipse.store.repository; + +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +import software.xdev.spring.data.eclipse.store.core.EntityProvider; +import software.xdev.spring.data.eclipse.store.repository.support.concurrency.ReadWriteLock; + + +public interface StorageCommunicator +{ + ReadWriteLock getReadWriteLock(); + + void store(Set nonEntitiesToStore, Class domainClass, List entitiesToStore); + + EntityProvider getEntityProvider(final Class clazz); + + long getEntityCount(Class domainClass); + + void delete(Class domainClass, T foundEntity); + + void deleteAll(Class domainClass); +} diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreCrudRepository.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreCrudRepository.java index 0d4f8df1..fc9d7e84 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreCrudRepository.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreCrudRepository.java @@ -15,14 +15,13 @@ */ package software.xdev.spring.data.eclipse.store.repository.interfaces.lazy; -import org.eclipse.serializer.reference.Lazy; import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.NoRepositoryBean; @SuppressWarnings("java:S119") @NoRepositoryBean -public interface LazyEclipseStoreCrudRepository extends CrudRepository, ID> +public interface LazyEclipseStoreCrudRepository extends CrudRepository { /** * @inheritDoc Caution with referenced objects!
If you are deleting an object that is referenced by @@ -40,15 +39,6 @@ public interface LazyEclipseStoreCrudRepository extends CrudRepositoryCaution with referenced objects!
If you are deleting an object that is referenced by - * another object, the behavior of this function may differ from what you are used to! - *

- * For more information see {@link #deleteById(Object)} - *

- */ - void deleteEntity(T entity); - /** * @inheritDoc Caution with referenced objects!
If you are deleting an object that is referenced by * another object, the behavior of this function may differ from what you are used to! @@ -57,7 +47,7 @@ public interface LazyEclipseStoreCrudRepository extends CrudRepository */ @Override - void delete(Lazy entity); + void delete(T entity); /** * @inheritDoc Caution with referenced objects!
If you are deleting an object that is referenced by @@ -77,16 +67,7 @@ public interface LazyEclipseStoreCrudRepository extends CrudRepository */ @Override - void deleteAll(Iterable> entities); - - /** - * @inheritDoc Caution with referenced objects!
If you are deleting an object that is referenced by - * another object, the behavior of this function may differ from what you are used to! - *

- * For more information see {@link #deleteById(Object)} - *

- */ - void deleteAllEntities(Iterable entities); + void deleteAll(Iterable entities); /** * @inheritDoc Caution with referenced objects!
If you are deleting an object that is referenced by diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreCustomRepository.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreCustomRepository.java index 86f55709..a251c05b 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreCustomRepository.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreCustomRepository.java @@ -22,6 +22,6 @@ @SuppressWarnings("java:S119") @NoRepositoryBean -public interface LazyEclipseStoreCustomRepository extends Repository, ID> +public interface LazyEclipseStoreCustomRepository extends Repository { } diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreListCrudRepository.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreListCrudRepository.java index 40983eaa..46e6e209 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreListCrudRepository.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreListCrudRepository.java @@ -15,16 +15,13 @@ */ package software.xdev.spring.data.eclipse.store.repository.interfaces.lazy; -import java.util.List; - -import org.eclipse.serializer.reference.Lazy; import org.springframework.data.repository.ListCrudRepository; import org.springframework.data.repository.NoRepositoryBean; @SuppressWarnings("java:S119") @NoRepositoryBean -public interface LazyEclipseStoreListCrudRepository extends ListCrudRepository, ID> +public interface LazyEclipseStoreListCrudRepository extends ListCrudRepository { /** * @inheritDoc Caution with referenced objects!
If you are deleting an object that is referenced by @@ -34,26 +31,7 @@ public interface LazyEclipseStoreListCrudRepository extends ListCrudRepos *

*/ @Override - void deleteById(ID id); - - /** - * @inheritDoc Caution with referenced objects!
If you are deleting an object that is referenced by - * another object, the behavior of this function may differ from what you are used to! - *

- * For more information see {@link LazyEclipseStoreCrudRepository#deleteById(Object)} - *

- */ - @Override - void delete(Lazy entity); - - /** - * @inheritDoc Caution with referenced objects!
If you are deleting an object that is referenced by - * another object, the behavior of this function may differ from what you are used to! - *

- * For more information see {@link LazyEclipseStoreCrudRepository#deleteById(Object)} - *

- */ - void deleteEntity(T entity); + void delete(T entity); /** * @inheritDoc Caution with referenced objects!
If you are deleting an object that is referenced by @@ -73,16 +51,7 @@ public interface LazyEclipseStoreListCrudRepository extends ListCrudRepos *

*/ @Override - void deleteAll(Iterable> entities); - - /** - * @inheritDoc Caution with referenced objects!
If you are deleting an object that is referenced by - * another object, the behavior of this function may differ from what you are used to! - *

- * For more information see {@link LazyEclipseStoreCrudRepository#deleteById(Object)} - *

- */ - void deleteAllEntities(Iterable entities); + void deleteAll(Iterable entities); /** * @inheritDoc Caution with referenced objects!
If you are deleting an object that is referenced by @@ -93,8 +62,4 @@ public interface LazyEclipseStoreListCrudRepository extends ListCrudRepos */ @Override void deleteAll(); - - List saveAllEntities(Iterable entities); - - S saveEntity(S entity); } diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreListPagingAndSortingRepositoryRepository.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreListPagingAndSortingRepositoryRepository.java index 85159e08..686c1a02 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreListPagingAndSortingRepositoryRepository.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreListPagingAndSortingRepositoryRepository.java @@ -23,6 +23,6 @@ @SuppressWarnings("java:S119") @NoRepositoryBean public interface LazyEclipseStoreListPagingAndSortingRepositoryRepository - extends ListPagingAndSortingRepository, ID> + extends ListPagingAndSortingRepository { } diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStorePagingAndSortingRepositoryRepository.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStorePagingAndSortingRepositoryRepository.java index 0aa17954..dee8d49b 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStorePagingAndSortingRepositoryRepository.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStorePagingAndSortingRepositoryRepository.java @@ -23,6 +23,6 @@ @SuppressWarnings("java:S119") @NoRepositoryBean public interface LazyEclipseStorePagingAndSortingRepositoryRepository - extends PagingAndSortingRepository, ID> + extends PagingAndSortingRepository { } diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreQueryByExampleExecutor.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreQueryByExampleExecutor.java index 2fb56b8e..be1ccfed 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreQueryByExampleExecutor.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreQueryByExampleExecutor.java @@ -22,6 +22,6 @@ @SuppressWarnings("java:S119") @NoRepositoryBean -public interface LazyEclipseStoreQueryByExampleExecutor extends QueryByExampleExecutor> +public interface LazyEclipseStoreQueryByExampleExecutor extends QueryByExampleExecutor { } diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreRepository.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreRepository.java index 00b23ff8..e1b5e9c6 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreRepository.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreRepository.java @@ -28,6 +28,6 @@ public interface LazyEclipseStoreRepository LazyEclipseStoreListCrudRepository, LazyEclipseStoreListPagingAndSortingRepositoryRepository, LazyEclipseStoreQueryByExampleExecutor, - EclipseStoreRepository, ID> + EclipseStoreRepository { } diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/by/example/EclipseStoreFetchableFluentQuery.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/by/example/EclipseStoreFetchableFluentQuery.java index 4e7d4aec..5fb5b877 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/by/example/EclipseStoreFetchableFluentQuery.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/by/example/EclipseStoreFetchableFluentQuery.java @@ -25,7 +25,7 @@ import org.springframework.data.domain.Sort; import org.springframework.data.repository.query.FluentQuery; -import software.xdev.spring.data.eclipse.store.repository.EclipseStoreStorage; +import software.xdev.spring.data.eclipse.store.repository.StorageCommunicator; import software.xdev.spring.data.eclipse.store.repository.query.criteria.CriteriaByExample; import software.xdev.spring.data.eclipse.store.repository.query.executors.CountQueryExecutor; import software.xdev.spring.data.eclipse.store.repository.query.executors.ExistsQueryExecutor; @@ -43,14 +43,14 @@ public class EclipseStoreFetchableFluentQuery implements FluentQ private final WorkingCopier copier; private final Example example; private final Class domainClass; - private final EclipseStoreStorage storage; + private final StorageCommunicator storage; private final Sort sort; public EclipseStoreFetchableFluentQuery( final WorkingCopier copier, final Example example, final Class domainClass, - final EclipseStoreStorage storage, + final StorageCommunicator storage, final Sort sort ) { diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/EntityData.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/EntityData.java index f0c3d60e..1ed25d39 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/EntityData.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/EntityData.java @@ -24,9 +24,13 @@ /** + * This is a object for all versions <2.4.0 and is used for upgrading to the new root. + * @deprecated should not be initialised anymore. Version for <2.4.0 + * * @param type of entity to store * @param type of id of the entity to store. Can be {@link Void} if no ID is used. */ +@Deprecated(forRemoval = false, since = "2.4.0") public class EntityData { private final IdentitySet entities; diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/RootDataV2.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/RootDataV2.java index 4cca1a0c..5cbaf6c8 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/RootDataV2.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/RootDataV2.java @@ -33,7 +33,7 @@ public RootDataV2() this.entityLists = new HashMap<>(); } - public Object getEntityListsToStore() + public Map> getEntityListsToStore() { return this.entityLists; } diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/VersionedRoot.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/VersionedRoot.java index 19a70e75..4fe3a20c 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/VersionedRoot.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/VersionedRoot.java @@ -19,6 +19,7 @@ import software.xdev.micromigration.version.Versioned; import software.xdev.spring.data.eclipse.store.repository.EclipseStoreMigrator; import software.xdev.spring.data.eclipse.store.repository.Root; +import software.xdev.spring.data.eclipse.store.repository.root.v2_4.RootDataV2_4; public class VersionedRoot implements Versioned @@ -27,7 +28,9 @@ public class VersionedRoot implements Versioned private Root rootDataV1; - private final RootDataV2 rootDataV2; + private RootDataV2 rootDataV2; + + private final RootDataV2_4 rootDataV2_4; public VersionedRoot() { @@ -41,6 +44,7 @@ public VersionedRoot(final Root rootDataV1) { this.rootDataV1 = rootDataV1; this.rootDataV2 = new RootDataV2(); + this.rootDataV2_4 = new RootDataV2_4(); if(rootDataV1 != null) { this.version = new MigrationVersion(0, 0, 0); @@ -61,14 +65,21 @@ public RootDataV2 getRootDataV2() return this.rootDataV2; } + @SuppressWarnings("checkstyle:MethodName") + public RootDataV2_4 getRootDataV2_4() + { + return rootDataV2_4; + } + public void clearOldRootData() { this.rootDataV1 = null; + this.rootDataV2 = null; } - public RootDataV2 getCurrentRootData() + public RootDataV2_4 getCurrentRootData() { - return this.rootDataV2; + return this.rootDataV2_4; } @Override diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/update/scripts/v2_4_0_InitializeLazy.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/update/scripts/v2_4_0_InitializeLazy.java new file mode 100644 index 00000000..92bdcea8 --- /dev/null +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/update/scripts/v2_4_0_InitializeLazy.java @@ -0,0 +1,74 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.repository.root.update.scripts; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import software.xdev.micromigration.eclipsestore.MigrationEmbeddedStorageManager; +import software.xdev.micromigration.scripts.Context; +import software.xdev.spring.data.eclipse.store.repository.root.EntityData; +import software.xdev.spring.data.eclipse.store.repository.root.RootDataV2; +import software.xdev.spring.data.eclipse.store.repository.root.VersionedRoot; + + +/** + * Copies elements from the old Root({@link software.xdev.spring.data.eclipse.store.repository.Root} to the newer + * version of Root({@link RootDataV2}). + *

+ * All migration scripts must be added to + * {@link software.xdev.spring.data.eclipse.store.repository.EclipseStoreMigrator#SCRIPTS}! + */ +@SuppressWarnings("checkstyle:TypeName") +public class v2_4_0_InitializeLazy extends LoggingUpdateScript +{ + private static final Logger LOG = LoggerFactory.getLogger(v2_4_0_InitializeLazy.class); + + @Override + public void loggedMigrate(final Context context) + { + final VersionedRoot versionedRoot = context.getMigratingObject(); + versionedRoot.getRootDataV2().getEntityListsToStore().forEach( + (entityName, entities) -> + { + final EntityData entityData = + versionedRoot.getRootDataV2_4().getEntityData(entityName); + // TODO + // TODO + // TODO + // TODO + if(entityData == null) + { + LOG.warn("Dropping entities {} because there is no repository in the new root.", entityName); + } + entities.forEach(entity -> entityData.ensureEntityAndReturnObjectsToStore(entity)); + context.getStorageManager().getNativeStorageManager().storeAll(entityData.getObjectsToStore()); + LOG.info("Migrated entities {}.", entityName); + } + ); + versionedRoot.getRootDataV1().getLastIds().forEach( + (entityName, lastId) -> + { + final EntityData entityData = versionedRoot.getRootDataV2().getEntityData(entityName); + entityData.setLastId(lastId); + context.getStorageManager().store(entityData); + LOG.info("Migrated last id of entities {}.", entityName); + } + ); + versionedRoot.clearOldRootData(); + context.getStorageManager().store(versionedRoot); + } +} diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/EntityData.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/EntityData.java new file mode 100644 index 00000000..b61059fc --- /dev/null +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/EntityData.java @@ -0,0 +1,54 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.repository.root.v2_4; + +import java.util.Collection; +import java.util.HashMap; +import java.util.function.Function; + +import software.xdev.spring.data.eclipse.store.core.IdentitySet; + + +/** + * @param type of entity to store + * @param type of id of the entity to store. Can be {@link Void} if no ID is used. + */ +public interface EntityData +{ + + /** + * Accepts {@code null} if no id field is defined + */ + void setIdGetter(final Function idGetter); + + IdentitySet getEntities(); + + ID getLastId(); + + HashMap getEntitiesById(); + + long getEntityCount(); + + void setLastId(final Object lastId); + + Collection ensureEntityAndReturnObjectsToStore(final T entityToStore); + + Collection getObjectsToStore(); + + Collection removeEntityAndReturnObjectsToStore(final T entityToRemove); + + Collection removeAllEntitiesAndReturnObjectsToStore(); +} diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/RootDataV2_4.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/RootDataV2_4.java new file mode 100644 index 00000000..fdd3291a --- /dev/null +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/RootDataV2_4.java @@ -0,0 +1,115 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.repository.root.v2_4; + +import java.util.HashMap; +import java.util.Map; +import java.util.function.Function; + + +/** + * This is the actually stored object. + */ +@SuppressWarnings("java:S119") +public class RootDataV2_4 +{ + private final Map> entityLists; + private final Map> lazyEntityLists; + + public RootDataV2_4() + { + this.entityLists = new HashMap<>(); + this.lazyEntityLists = new HashMap<>(); + } + + public Object getEntityListsToStore() + { + return this.entityLists; + } + + public Object getLazyEntityListsToStore() + { + return this.lazyEntityLists; + } + + public long getEntityTypesCount() + { + return this.entityLists.size(); + } + + public long getEntityCount() + { + return this.entityLists.values().stream().map(EntityData::getEntityCount).reduce(0L, Long::sum) + + this.lazyEntityLists.values().stream().map(EntityData::getEntityCount).reduce(0L, Long::sum); + } + + public EntityData getEntityData(final Class entityClass) + { + return this.getEntityData(this.getEntityName(entityClass)); + } + + public EntityData getEntityData(final String entityClassName) + { + return (EntityData)this.entityLists.get(entityClassName); + } + + public EntityData getLazyEntityData(final Class entityClass) + { + return this.getLazyEntityData(this.getEntityName(entityClass)); + } + + public EntityData getLazyEntityData(final String entityClassName) + { + return (EntityData)this.lazyEntityLists.get(entityClassName); + } + + public void createNewEntityData(final Class entityClass, final Function idGetter) + { + final EntityData + entityData = new EntityData<>(); + entityData.setIdGetter(idGetter); + this.entityLists.put(this.getEntityName(entityClass), entityData); + } + + public void createNewLazyEntityData(final Class entityClass, final Function idGetter) + { + final EntityData + entityData = new EntityData<>(); + entityData.setIdGetter(idGetter); + this.entityLists.put(this.getEntityName(entityClass), entityData); + } + + private String getEntityName(final Class classToRegister) + { + return classToRegister.getName(); + } + + public Object getLastId(final Class entityClass) + { + final EntityData entityData = this.entityLists.get(this.getEntityName(entityClass)); + return entityData == null ? null : entityData.getLastId(); + } + + public void setLastId(final Class entityClass, final Object lastId) + { + this.entityLists.get(this.getEntityName(entityClass)).setLastId(lastId); + } + + public Object getObjectsToStoreAfterNewLastId(final Class entityClass) + { + return this.entityLists.get(this.getEntityName(entityClass)); + } +} diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/EclipseStoreRepositoryFactory.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/EclipseStoreRepositoryFactory.java index 36581fe9..c2ac12bd 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/EclipseStoreRepositoryFactory.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/EclipseStoreRepositoryFactory.java @@ -98,7 +98,9 @@ private WorkingCopier createWorkingCopier( @Nonnull protected Object getTargetRepository(@Nonnull final RepositoryInformation metadata) { - final EclipseStoreRepository existingRepository = this.storage.getRepository(metadata.getDomainType()); + Class domainType = metadata.getDomainType(); + + final EclipseStoreRepository existingRepository = this.storage.getRepository(domainType); if(existingRepository != null) { return existingRepository; @@ -107,10 +109,10 @@ protected Object getTargetRepository(@Nonnull final RepositoryInformation metada return this.getTargetRepositoryViaReflection( metadata, this.storage, - this.createWorkingCopier(metadata.getDomainType(), this.storage), - metadata.getDomainType(), + this.createWorkingCopier(domainType, this.storage), + domainType, this.transactionManager, - this.storage.ensureIdManager(metadata.getDomainType()) + this.storage.ensureIdManager(domainType) ); } diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/LazySimpleEclipseStoreRepository.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/LazySimpleEclipseStoreRepository.java index 05510b04..e6270354 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/LazySimpleEclipseStoreRepository.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/LazySimpleEclipseStoreRepository.java @@ -15,9 +15,19 @@ */ package software.xdev.spring.data.eclipse.store.repository.support; +import java.util.Collection; import java.util.List; +import java.util.Optional; +import java.util.function.Function; + +import jakarta.annotation.Nonnull; import org.eclipse.serializer.reference.Lazy; +import org.springframework.data.domain.Example; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.data.repository.query.FluentQuery; import software.xdev.spring.data.eclipse.store.repository.EclipseStoreStorage; import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreCrudRepository; @@ -33,7 +43,6 @@ @SuppressWarnings("java:S119") public class LazySimpleEclipseStoreRepository - extends SimpleEclipseStoreRepository, ID> implements LazyEclipseStoreRepository, LazyEclipseStorePagingAndSortingRepositoryRepository, @@ -42,6 +51,7 @@ public class LazySimpleEclipseStoreRepository LazyEclipseStoreListCrudRepository, LazyEclipseStoreQueryByExampleExecutor { + private final SimpleEclipseStoreRepository, ID> repository; public LazySimpleEclipseStoreRepository( final EclipseStoreStorage storage, @@ -51,30 +61,136 @@ public LazySimpleEclipseStoreRepository( final IdManager, ID> idManager ) { - super(storage, copier, domainClass, transactionManager, idManager); + this.repository = + new SimpleEclipseStoreRepository<>(storage, copier, domainClass, transactionManager, idManager); + } + + @Override + public void deleteById(@Nonnull final ID id) + { + repository.deleteById(id); + } + + public List saveBulk(final Collection entities) + { + return repository.saveBulk(entities); + } + + @Nonnull + public S save(@Nonnull final S entity) + { + return repository.save(entity); + } + + @Nonnull + public List saveAll(@Nonnull final Iterable entities) + { + return repository.saveAll(entities); + } + + @Override + @Nonnull + public Optional findById(@Nonnull final ID id) + { + return repository.findById(id); } @Override - public void deleteEntity(final T entity) + public boolean existsById(@Nonnull final ID id) { + return repository.existsById(id); + } + @Override + @Nonnull + public List findAll() + { + return repository.findAll(); } @Override - public void deleteAllEntities(final Iterable entities) + @Nonnull + public List findAllById(@Nonnull final Iterable idsToFind) { + return repository.findAllById(idsToFind); + } + @Override + public long count() + { + return repository.count(); + } + + public void delete(@Nonnull final T entity) + { + repository.delete(entity); } @Override - public List saveAllEntities(final Iterable entities) + public void deleteAllById(final Iterable ids) + { + repository.deleteAllById(ids); + } + + public void deleteAll(final Iterable entities) { - return List.of(); + repository.deleteAll(entities); } @Override - public S saveEntity(final S entity) + public void deleteAll() + { + repository.deleteAll(); + } + + @Override + @Nonnull + public List findAll(@Nonnull final Sort sort) + { + return repository.findAll(sort); + } + + @Override + @Nonnull + public Page findAll(@Nonnull final Pageable pageable) + { + return repository.findAll(pageable).; + } + + public Optional findOne(final Example example) + { + return repository.findOne(example); + } + + public Iterable findAll(final Example example) + { + return repository.findAll(example); + } + + public Iterable findAll(final Example example, final Sort sort) + { + return repository.findAll(example, sort); + } + + public Page findAll(final Example example, final Pageable pageable) + { + return repository.findAll(example, pageable); + } + + public long count(final Example example) + { + return repository.count(example); + } + + public boolean exists(final Example example) + { + return repository.exists(example); + } + + public R findBy( + final Example example, + final Function, R> queryFunction) { - return null; + return repository.findBy(example, queryFunction); } } diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/SimpleEclipseStoreRepository.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/SimpleEclipseStoreRepository.java index a8945976..267a30a7 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/SimpleEclipseStoreRepository.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/SimpleEclipseStoreRepository.java @@ -34,7 +34,7 @@ import org.springframework.data.domain.Sort; import org.springframework.data.repository.query.FluentQuery; -import software.xdev.spring.data.eclipse.store.repository.EclipseStoreStorage; +import software.xdev.spring.data.eclipse.store.repository.StorageCommunicator; import software.xdev.spring.data.eclipse.store.repository.access.AccessHelper; import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreCrudRepository; import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreListCrudRepository; @@ -68,14 +68,14 @@ public class SimpleEclipseStoreRepository EclipseStoreQueryByExampleExecutor { private static final Logger LOG = LoggerFactory.getLogger(SimpleEclipseStoreRepository.class); - private final EclipseStoreStorage storage; + private final StorageCommunicator storage; private final Class domainClass; private final WorkingCopier copier; private final EclipseStoreTransactionManager transactionManager; private final IdManager idManager; public SimpleEclipseStoreRepository( - final EclipseStoreStorage storage, + final StorageCommunicator storage, final WorkingCopier copier, final Class domainClass, final EclipseStoreTransactionManager transactionManager, From 9abed063eed5db92ee538f8b9d52a5f1184a2152 Mon Sep 17 00:00:00 2001 From: XDEV Renovate Bot Date: Fri, 6 Dec 2024 02:38:52 +0000 Subject: [PATCH 35/54] Update dependency @antora/cli to v3.1.10 --- docs/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/package.json b/docs/package.json index d8693534..ca52135e 100644 --- a/docs/package.json +++ b/docs/package.json @@ -3,7 +3,7 @@ "@antora/lunr-extension": "^1.0.0-alpha.8" }, "devDependencies": { - "@antora/cli": "3.1.9", + "@antora/cli": "3.1.10", "@antora/site-generator": "3.1.9" } } \ No newline at end of file From 891c338eccc16573152f14d8bdc9e3df7b72cf80 Mon Sep 17 00:00:00 2001 From: XDEV Renovate Bot Date: Fri, 6 Dec 2024 02:38:54 +0000 Subject: [PATCH 36/54] Update dependency @antora/site-generator to v3.1.10 --- docs/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/package.json b/docs/package.json index d8693534..42549ce5 100644 --- a/docs/package.json +++ b/docs/package.json @@ -4,6 +4,6 @@ }, "devDependencies": { "@antora/cli": "3.1.9", - "@antora/site-generator": "3.1.9" + "@antora/site-generator": "3.1.10" } } \ No newline at end of file From a46bdf1e32cd2493304c5a691509ebc1a741231a Mon Sep 17 00:00:00 2001 From: JohannesRabauer Date: Fri, 6 Dec 2024 11:42:46 +0100 Subject: [PATCH 37/54] Implemented LazyRepositories, new EntityData and refactoring --- .../integration/JpaImportExplicitTest.java | 2 +- .../store/jpa/integration/JpaImportTest.java | 2 +- .../store/core/EntityListProvider.java | 2 - .../eclipse/store/core/EntityProvider.java | 3 +- .../repository/EclipseStoreMigrator.java | 4 +- .../store/repository/EclipseStoreStorage.java | 99 ++++------- .../store/repository/EntitySetCollector.java | 2 +- .../store/repository/StorageCommunicator.java | 26 ++- ...StoreRepositoryConfigurationExtension.java | 9 +- ...eStoreListPagingAndSortingRepository.java} | 3 +- ...lipseStorePagingAndSortingRepository.java} | 3 +- .../lazy/LazyEclipseStoreRepository.java | 3 +- .../store/repository/root/RootDataV2.java | 6 +- .../store/repository/root/VersionedRoot.java | 1 + .../scripts/v2_0_0_InitializeVersioning.java | 2 +- .../update/scripts/v2_4_0_InitializeLazy.java | 29 +-- .../repository/root/v2_4/LazyEntityData.java | 134 ++++++++++++++ .../root/v2_4/NonLazyEntityData.java | 134 ++++++++++++++ .../repository/root/v2_4/RootDataV2_4.java | 25 +-- .../EclipseStoreRepositoryFactory.java | 24 ++- .../LazySimpleEclipseStoreRepository.java | 166 ++---------------- .../support/SimpleEclipseStoreRepository.java | 5 + .../reposyncer/RepositorySynchronizer.java | 2 +- .../SimpleRepositorySynchronizer.java | 10 +- .../store/helper/DummyEntityProvider.java | 5 +- .../isolated/tests/lazy/LazyTest.java | 13 +- 26 files changed, 412 insertions(+), 302 deletions(-) rename spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/{LazyEclipseStoreListPagingAndSortingRepositoryRepository.java => LazyEclipseStoreListPagingAndSortingRepository.java} (88%) rename spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/{LazyEclipseStorePagingAndSortingRepositoryRepository.java => LazyEclipseStorePagingAndSortingRepository.java} (88%) create mode 100644 spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/LazyEntityData.java create mode 100644 spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/NonLazyEntityData.java diff --git a/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/JpaImportExplicitTest.java b/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/JpaImportExplicitTest.java index 70e452fb..112bf8cf 100644 --- a/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/JpaImportExplicitTest.java +++ b/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/JpaImportExplicitTest.java @@ -63,7 +63,7 @@ void testEclipseStoreImportExplicitNoComponent() this.configuration.getStorageInstance().stop(); Assertions.assertEquals( 1, - this.configuration.getStorageInstance().getEntityCount(PersonToTestInJpa.class), + this.configuration.getStorageInstance().getNonLazyCommunicator().getEntityCount(PersonToTestInJpa.class), "After restart the imported entities are not there anymore."); } } diff --git a/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/JpaImportTest.java b/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/JpaImportTest.java index b1a3bf03..50c504e0 100644 --- a/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/JpaImportTest.java +++ b/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/JpaImportTest.java @@ -72,7 +72,7 @@ void testEclipseStoreImport(@Autowired final EclipseStoreDataImporterComponent e this.configuration.getStorageInstance().stop(); Assertions.assertEquals( 1, - this.configuration.getStorageInstance().getEntityCount(PersonToTestInJpa.class), + this.configuration.getStorageInstance().getNonLazyCommunicator().getEntityCount(PersonToTestInJpa.class), "After restart the imported entities are not there anymore."); } diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/core/EntityListProvider.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/core/EntityListProvider.java index 6114fef8..7a538164 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/core/EntityListProvider.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/core/EntityListProvider.java @@ -18,6 +18,4 @@ public interface EntityListProvider { EntityProvider getEntityProvider(final Class clazz); - - long getEntityCount(final Class clazz); } diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/core/EntityProvider.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/core/EntityProvider.java index 8a8ff19f..f0dcb709 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/core/EntityProvider.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/core/EntityProvider.java @@ -23,7 +23,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import software.xdev.spring.data.eclipse.store.repository.root.EntityData; +import software.xdev.spring.data.eclipse.store.repository.root.v2_4.EntityData; @SuppressWarnings("java:S119") @@ -56,6 +56,7 @@ public long size() return this.stream().count(); } + @SuppressWarnings("unchecked") public Optional findAnyEntityWithId(final ID id) { return (Optional)this.entityDataList diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreMigrator.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreMigrator.java index f37eaf5d..695f0504 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreMigrator.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreMigrator.java @@ -25,13 +25,15 @@ import software.xdev.micromigration.version.MigrationVersion; import software.xdev.spring.data.eclipse.store.repository.root.VersionedRoot; import software.xdev.spring.data.eclipse.store.repository.root.update.scripts.v2_0_0_InitializeVersioning; +import software.xdev.spring.data.eclipse.store.repository.root.update.scripts.v2_4_0_InitializeLazy; public final class EclipseStoreMigrator { public static final VersionAgnosticMigrationScript[] SCRIPTS = new VersionAgnosticMigrationScript[]{ - new v2_0_0_InitializeVersioning() + new v2_0_0_InitializeVersioning(), + new v2_4_0_InitializeLazy() }; private EclipseStoreMigrator() diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreStorage.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreStorage.java index a96f5f79..67e3c1d5 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreStorage.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreStorage.java @@ -39,8 +39,9 @@ import software.xdev.spring.data.eclipse.store.repository.config.EclipseStoreClientConfiguration; import software.xdev.spring.data.eclipse.store.repository.config.EclipseStoreStorageFoundationProvider; import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository; -import software.xdev.spring.data.eclipse.store.repository.root.EntityData; import software.xdev.spring.data.eclipse.store.repository.root.VersionedRoot; +import software.xdev.spring.data.eclipse.store.repository.root.v2_4.EntityData; +import software.xdev.spring.data.eclipse.store.repository.support.SimpleEclipseStoreRepository; import software.xdev.spring.data.eclipse.store.repository.support.concurrency.ReadWriteLock; import software.xdev.spring.data.eclipse.store.repository.support.concurrency.ReentrantJavaReadWriteLock; import software.xdev.spring.data.eclipse.store.repository.support.copier.version.EntityVersionIncrementer; @@ -55,11 +56,15 @@ @SuppressWarnings("java:S119") public class EclipseStoreStorage - implements EntityListProvider, IdManagerProvider, VersionManagerProvider, PersistableChecker, ObjectSwizzling + implements EntityListProvider, + IdManagerProvider, + VersionManagerProvider, + PersistableChecker, + ObjectSwizzling, + StorageCommunicator { private static final Logger LOG = LoggerFactory.getLogger(EclipseStoreStorage.class); - private final Map, EclipseStoreRepository> entityClassToRepository = new HashMap<>(); - private final Map, EclipseStoreRepository> lazyEntityClassToRepository = new HashMap<>(); + private final Map, SimpleEclipseStoreRepository> entityClassToRepository = new HashMap<>(); /** * "Why are the IdManagers seperated from the repositories?" - Because there might be entities for which there are * no repositories, but they still have IDs. @@ -107,8 +112,7 @@ private synchronized void ensureEntitiesInRoot() { if(this.storageManager == null) { - final EmbeddedStorageFoundation embeddedStorageFoundation = - this.startStorageManager(); + final EmbeddedStorageFoundation embeddedStorageFoundation = this.startStorageManager(); this.persistenceChecker = new RelayedPersistenceChecker(embeddedStorageFoundation); this.initRoot(); LOG.info( @@ -120,6 +124,7 @@ private synchronized void ensureEntitiesInRoot() } } + @SuppressWarnings("deprecation") private EmbeddedStorageFoundation startStorageManager() { LOG.info("Starting storage..."); @@ -161,11 +166,6 @@ else if(!(embeddedStorageManager.root() instanceof VersionedRoot)) return this.entityClassToRepository.get(entityClass); } - public EclipseStoreRepository getLazyRepository(final Class entityClass) - { - return this.lazyEntityClassToRepository.get(entityClass); - } - private void initRoot() { if(LOG.isDebugEnabled()) @@ -175,7 +175,6 @@ private void initRoot() this.repositorySynchronizer = new SimpleRepositorySynchronizer(this.root.getCurrentRootData()); this.ensureEntityData(); - this.ensureLazyEntityData(); this.entitySetCollector = new EntitySetCollector( this.root.getCurrentRootData()::getEntityData, @@ -207,39 +206,19 @@ private void ensureEntityData() } } - private void ensureLazyEntityData() + public void createNewEntityData(final Class entityClass, final VersionedRoot root) { - boolean entityListMustGetStored = false; - for(final Class entityClass : this.lazyEntityClassToRepository.keySet()) + final IdManager idManager = this.ensureIdManager(entityClass); + if(this.entityClassToRepository.get(entityClass).isLazy()) { - if(this.root.getCurrentRootData().getLazyEntityData(entityClass) == null) - { - this.createNewLazyEntityData(entityClass, this.root); - entityListMustGetStored = true; - } - else - { - this.setIdManagerForEntityData(entityClass, this.root); - } + root.getCurrentRootData().createNewLazyEntityData(entityClass, idManager::getId); } - if(entityListMustGetStored) + else { - this.storageManager.store(this.root.getCurrentRootData().getLazyEntityListsToStore()); + root.getCurrentRootData().createNewEntityData(entityClass, idManager::getId); } } - private void createNewEntityData(final Class entityClass, final VersionedRoot root) - { - final IdManager idManager = this.ensureIdManager(entityClass); - root.getCurrentRootData().createNewEntityData(entityClass, idManager::getId); - } - - private void createNewLazyEntityData(final Class entityClass, final VersionedRoot root) - { - final IdManager idManager = this.ensureIdManager(entityClass); - root.getCurrentRootData().createNewLazyEntityData(entityClass, idManager::getId); - } - private void setIdManagerForEntityData(final Class entityClass, final VersionedRoot root) { final IdManager idManager = this.ensureIdManager(entityClass); @@ -254,9 +233,10 @@ private void setIdManagerForEntityData(final Class entityClass, final } } - public synchronized void registerEntity( + @Override + public synchronized void registerEntity( final Class classToRegister, - final EclipseStoreRepository repository) + final SimpleEclipseStoreRepository repository) { if(this.entityClassToRepository.containsKey(classToRegister)) { @@ -278,12 +258,6 @@ private EntityData getEntityData(final Class clazz) return this.readWriteLock.read(() -> this.root.getCurrentRootData().getEntityData(clazz)); } - private EntityData getLazyEntityData(final Class clazz) - { - this.ensureEntitiesInRoot(); - return this.readWriteLock.read(() -> this.root.getCurrentRootData().getLazyEntityData(clazz)); - } - @Override public EntityProvider getEntityProvider(final Class clazz) { @@ -291,20 +265,17 @@ public EntityProvider getEntityProvider(final Class clazz) return this.entitySetCollector.getRelatedIdentitySets(clazz); } - @SuppressWarnings("unchecked") @Override public long getEntityCount(final Class clazz) { this.ensureEntitiesInRoot(); - return this.readWriteLock.read( - () -> - { - final EntityData entityData = this.root.getCurrentRootData().getEntityData(clazz); - return entityData == null ? 0 : entityData.getEntityCount(); - } - ); + return this.readWriteLock.read(() -> { + final EntityData entityData = this.getEntityData(clazz); + return entityData == null ? 0 : entityData.getEntityCount(); + }); } + @Override public void store( final Collection nonEntitiesToStore, final Class clazz, @@ -315,7 +286,10 @@ public void store( () -> { final Collection entitiesAndPossiblyNonEntitiesToStore = - this.collectRootEntitiesToStore(clazz, entitiesToStore); + this.collectRootEntitiesToStore( + this.getEntityData(clazz), + clazz, + entitiesToStore); entitiesAndPossiblyNonEntitiesToStore.addAll(nonEntitiesToStore); if(LOG.isDebugEnabled()) { @@ -336,16 +310,14 @@ public void store( * Also collects the object-list to store, if necessary. */ private Collection collectRootEntitiesToStore( + final EntityData entityData, final Class clazz, final Iterable entitiesToStore) { - final EntityData entityData = this.getEntityData(clazz); - final EntityData lazyEntityData = this.getLazyEntityData(clazz); final Collection objectsToStore = new ArrayList<>(); for(final T entityToStore : entitiesToStore) { objectsToStore.addAll(entityData.ensureEntityAndReturnObjectsToStore(entityToStore)); - objectsToStore.addAll(lazyEntityData.ensureEntityAndReturnObjectsToStore(entityToStore)); objectsToStore.add(entityToStore); // Add the separate lists of entities to store. this.repositorySynchronizer.syncAndReturnChangedObjectLists(entityToStore).forEach( @@ -355,13 +327,14 @@ private Collection collectRootEntitiesToStore( return objectsToStore; } - public void delete(final Class clazz, final T entityToRemove) + @Override + public void delete(final Class clazz, final T entityToRemove) { this.ensureEntitiesInRoot(); this.readWriteLock.write( () -> { - final EntityData entityData = this.getEntityData(clazz); + final EntityData entityData = this.getEntityData(clazz); this.storageManager.storeAll(entityData.removeEntityAndReturnObjectsToStore(entityToRemove)); if(LOG.isDebugEnabled()) { @@ -371,13 +344,14 @@ public void delete(final Class clazz, final T entityToRemove) ); } - public void deleteAll(final Class clazz) + @Override + public void deleteAll(final Class clazz) { this.ensureEntitiesInRoot(); this.readWriteLock.write( () -> { - final EntityData entityData = this.getEntityData(clazz); + final EntityData entityData = this.getEntityData(clazz); final long oldSize = entityData.getEntityCount(); this.storageManager.storeAll(entityData.removeAllEntitiesAndReturnObjectsToStore()); if(LOG.isDebugEnabled()) @@ -518,6 +492,7 @@ public Object getObject(final long objectId) return this.storageManager.getObject(objectId); } + @Override public ReadWriteLock getReadWriteLock() { return this.readWriteLock; diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EntitySetCollector.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EntitySetCollector.java index 4ca0f8d4..10dae678 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EntitySetCollector.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EntitySetCollector.java @@ -24,7 +24,7 @@ import org.slf4j.LoggerFactory; import software.xdev.spring.data.eclipse.store.core.EntityProvider; -import software.xdev.spring.data.eclipse.store.repository.root.EntityData; +import software.xdev.spring.data.eclipse.store.repository.root.v2_4.EntityData; @SuppressWarnings("java:S119") diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/StorageCommunicator.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/StorageCommunicator.java index a11b6f98..4ce4eaae 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/StorageCommunicator.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/StorageCommunicator.java @@ -1,10 +1,24 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package software.xdev.spring.data.eclipse.store.repository; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; +import java.util.Collection; import software.xdev.spring.data.eclipse.store.core.EntityProvider; +import software.xdev.spring.data.eclipse.store.repository.support.SimpleEclipseStoreRepository; import software.xdev.spring.data.eclipse.store.repository.support.concurrency.ReadWriteLock; @@ -12,7 +26,9 @@ public interface StorageCommunicator { ReadWriteLock getReadWriteLock(); - void store(Set nonEntitiesToStore, Class domainClass, List entitiesToStore); + void store( + final Collection nonEntitiesToStore, final Class clazz, + final Iterable entitiesToStore); EntityProvider getEntityProvider(final Class clazz); @@ -21,4 +37,6 @@ public interface StorageCommunicator void delete(Class domainClass, T foundEntity); void deleteAll(Class domainClass); + + void registerEntity(Class domainClass, SimpleEclipseStoreRepository repository); } diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/config/EclipseStoreRepositoryConfigurationExtension.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/config/EclipseStoreRepositoryConfigurationExtension.java index 4cac26e9..5a39a185 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/config/EclipseStoreRepositoryConfigurationExtension.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/config/EclipseStoreRepositoryConfigurationExtension.java @@ -40,8 +40,8 @@ import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreCrudRepository; import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreCustomRepository; import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreListCrudRepository; -import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreListPagingAndSortingRepositoryRepository; -import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStorePagingAndSortingRepositoryRepository; +import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreListPagingAndSortingRepository; +import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStorePagingAndSortingRepository; import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreRepository; import software.xdev.spring.data.eclipse.store.repository.support.EclipseStoreRepositoryFactoryBean; @@ -64,6 +64,7 @@ public String getModuleName() */ @Override @Nonnull + @SuppressWarnings("deprecation") public String getModulePrefix() { return this.getModuleIdentifier(); @@ -130,8 +131,8 @@ protected Collection> getIdentifyingTypes() EclipseStoreListCrudRepository.class, LazyEclipseStoreRepository.class, LazyEclipseStoreCustomRepository.class, - LazyEclipseStorePagingAndSortingRepositoryRepository.class, - LazyEclipseStoreListPagingAndSortingRepositoryRepository.class, + LazyEclipseStorePagingAndSortingRepository.class, + LazyEclipseStoreListPagingAndSortingRepository.class, LazyEclipseStoreCrudRepository.class, LazyEclipseStoreListCrudRepository.class ); diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreListPagingAndSortingRepositoryRepository.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreListPagingAndSortingRepository.java similarity index 88% rename from spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreListPagingAndSortingRepositoryRepository.java rename to spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreListPagingAndSortingRepository.java index 686c1a02..9c25b3ff 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreListPagingAndSortingRepositoryRepository.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreListPagingAndSortingRepository.java @@ -15,14 +15,13 @@ */ package software.xdev.spring.data.eclipse.store.repository.interfaces.lazy; -import org.eclipse.serializer.reference.Lazy; import org.springframework.data.repository.ListPagingAndSortingRepository; import org.springframework.data.repository.NoRepositoryBean; @SuppressWarnings("java:S119") @NoRepositoryBean -public interface LazyEclipseStoreListPagingAndSortingRepositoryRepository +public interface LazyEclipseStoreListPagingAndSortingRepository extends ListPagingAndSortingRepository { } diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStorePagingAndSortingRepositoryRepository.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStorePagingAndSortingRepository.java similarity index 88% rename from spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStorePagingAndSortingRepositoryRepository.java rename to spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStorePagingAndSortingRepository.java index dee8d49b..05f5752d 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStorePagingAndSortingRepositoryRepository.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStorePagingAndSortingRepository.java @@ -15,14 +15,13 @@ */ package software.xdev.spring.data.eclipse.store.repository.interfaces.lazy; -import org.eclipse.serializer.reference.Lazy; import org.springframework.data.repository.NoRepositoryBean; import org.springframework.data.repository.PagingAndSortingRepository; @SuppressWarnings("java:S119") @NoRepositoryBean -public interface LazyEclipseStorePagingAndSortingRepositoryRepository +public interface LazyEclipseStorePagingAndSortingRepository extends PagingAndSortingRepository { } diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreRepository.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreRepository.java index e1b5e9c6..b879c552 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreRepository.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreRepository.java @@ -16,7 +16,6 @@ package software.xdev.spring.data.eclipse.store.repository.interfaces.lazy; import org.springframework.data.repository.NoRepositoryBean; -import org.eclipse.serializer.reference.Lazy; import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository; @@ -26,7 +25,7 @@ public interface LazyEclipseStoreRepository extends LazyEclipseStoreListCrudRepository, - LazyEclipseStoreListPagingAndSortingRepositoryRepository, + LazyEclipseStoreListPagingAndSortingRepository, LazyEclipseStoreQueryByExampleExecutor, EclipseStoreRepository { diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/RootDataV2.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/RootDataV2.java index 5cbaf6c8..56e9e4e1 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/RootDataV2.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/RootDataV2.java @@ -21,9 +21,11 @@ /** - * This is the actually stored object. + * This is a object for all versions <2.4.0 and is used for upgrading to the new root. + * @deprecated should not be initialised anymore. Version for <2.4.0 */ -@SuppressWarnings("java:S119") +@Deprecated(forRemoval = false, since = "2.4.0") +@SuppressWarnings({"java:S119", "unchecked"}) public class RootDataV2 { private final Map> entityLists; diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/VersionedRoot.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/VersionedRoot.java index 4fe3a20c..1af617e6 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/VersionedRoot.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/VersionedRoot.java @@ -22,6 +22,7 @@ import software.xdev.spring.data.eclipse.store.repository.root.v2_4.RootDataV2_4; +@SuppressWarnings("deprecation") public class VersionedRoot implements Versioned { private MigrationVersion version; diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/update/scripts/v2_0_0_InitializeVersioning.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/update/scripts/v2_0_0_InitializeVersioning.java index 7844a995..2aabbab4 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/update/scripts/v2_0_0_InitializeVersioning.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/update/scripts/v2_0_0_InitializeVersioning.java @@ -32,7 +32,7 @@ * All migration scripts must be added to * {@link software.xdev.spring.data.eclipse.store.repository.EclipseStoreMigrator#SCRIPTS}! */ -@SuppressWarnings("checkstyle:TypeName") +@SuppressWarnings({"checkstyle:TypeName", "deprecation"}) public class v2_0_0_InitializeVersioning extends LoggingUpdateScript { private static final Logger LOG = LoggerFactory.getLogger(v2_0_0_InitializeVersioning.class); diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/update/scripts/v2_4_0_InitializeLazy.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/update/scripts/v2_4_0_InitializeLazy.java index 92bdcea8..17eee7d6 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/update/scripts/v2_4_0_InitializeLazy.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/update/scripts/v2_4_0_InitializeLazy.java @@ -20,7 +20,6 @@ import software.xdev.micromigration.eclipsestore.MigrationEmbeddedStorageManager; import software.xdev.micromigration.scripts.Context; -import software.xdev.spring.data.eclipse.store.repository.root.EntityData; import software.xdev.spring.data.eclipse.store.repository.root.RootDataV2; import software.xdev.spring.data.eclipse.store.repository.root.VersionedRoot; @@ -32,7 +31,7 @@ * All migration scripts must be added to * {@link software.xdev.spring.data.eclipse.store.repository.EclipseStoreMigrator#SCRIPTS}! */ -@SuppressWarnings("checkstyle:TypeName") +@SuppressWarnings({"checkstyle:TypeName", "deprecation"}) public class v2_4_0_InitializeLazy extends LoggingUpdateScript { private static final Logger LOG = LoggerFactory.getLogger(v2_4_0_InitializeLazy.class); @@ -44,30 +43,14 @@ public void loggedMigrate(final Context { - final EntityData entityData = - versionedRoot.getRootDataV2_4().getEntityData(entityName); - // TODO - // TODO - // TODO - // TODO - if(entityData == null) - { - LOG.warn("Dropping entities {} because there is no repository in the new root.", entityName); - } - entities.forEach(entity -> entityData.ensureEntityAndReturnObjectsToStore(entity)); - context.getStorageManager().getNativeStorageManager().storeAll(entityData.getObjectsToStore()); + final software.xdev.spring.data.eclipse.store.repository.root.v2_4.EntityData + newEntityData = versionedRoot.getRootDataV2_4().getEntityData(entityName); + entities.getEntities().forEach(newEntityData::ensureEntityAndReturnObjectsToStore); + newEntityData.setLastId(entities.getLastId()); + context.getStorageManager().getNativeStorageManager().storeAll(newEntityData.getObjectsToStore()); LOG.info("Migrated entities {}.", entityName); } ); - versionedRoot.getRootDataV1().getLastIds().forEach( - (entityName, lastId) -> - { - final EntityData entityData = versionedRoot.getRootDataV2().getEntityData(entityName); - entityData.setLastId(lastId); - context.getStorageManager().store(entityData); - LOG.info("Migrated last id of entities {}.", entityName); - } - ); versionedRoot.clearOldRootData(); context.getStorageManager().store(versionedRoot); } diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/LazyEntityData.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/LazyEntityData.java new file mode 100644 index 00000000..3ac3104e --- /dev/null +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/LazyEntityData.java @@ -0,0 +1,134 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.repository.root.v2_4; + +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.function.Function; + +import software.xdev.spring.data.eclipse.store.core.IdentitySet; + + +/** + * @param type of entity to store + * @param type of id of the entity to store. Can be {@link Void} if no ID is used. + */ +public class LazyEntityData implements EntityData +{ + private final IdentitySet entities; + private ID lastId; + /** + * "Why do you keep the entites at two places? This seems like a waste of space." - Yes, it seems like it is + * duplicated information, but we need to be able to find an entity based on its identity as fast as possible + * ({@link #entities} and also find an entity based on its id {@link #entitiesById}. We could use the BiMaps + * provided by google and apache, but they implemented this also with two seperate lists so there is no benefit in + * using these. + */ + private final HashMap entitiesById; + + private transient Function idGetter; + + public LazyEntityData() + { + this.entities = new IdentitySet<>(); + this.entitiesById = new HashMap<>(); + } + + /** + * Accepts {@code null} if no id field is defined + */ + public void setIdGetter(final Function idGetter) + { + this.idGetter = idGetter; + + this.ensureEntitiesAndEntitiesByIdAreTheSameSize(); + } + + private void ensureEntitiesAndEntitiesByIdAreTheSameSize() + { + if(this.idGetter != null && this.entities.size() != this.entitiesById.size()) + { + this.entitiesById.clear(); + this.entities.forEach(entity -> this.entitiesById.put(this.idGetter.apply(entity), entity)); + } + if(this.idGetter == null) + { + this.entitiesById.clear(); + } + } + + public IdentitySet getEntities() + { + return this.entities; + } + + public ID getLastId() + { + return this.lastId; + } + + public HashMap getEntitiesById() + { + return this.entitiesById; + } + + public long getEntityCount() + { + return this.entities.size(); + } + + public void setLastId(final Object lastId) + { + this.lastId = (ID)lastId; + } + + public Collection ensureEntityAndReturnObjectsToStore(final T entityToStore) + { + if(!this.getEntities().contains(entityToStore)) + { + this.entities.add(entityToStore); + if(this.idGetter != null) + { + this.entitiesById.put(this.idGetter.apply(entityToStore), entityToStore); + } + return this.getObjectsToStore(); + } + return List.of(); + } + + public Collection getObjectsToStore() + { + return List.of(this.entities.getInternalMap(), this.entitiesById); + } + + public Collection removeEntityAndReturnObjectsToStore(final T entityToRemove) + { + this.entities.remove(entityToRemove); + if(this.idGetter != null) + { + this.entitiesById.remove(this.idGetter.apply(entityToRemove)); + } + return this.getObjectsToStore(); + } + + public Collection removeAllEntitiesAndReturnObjectsToStore() + { + this.entities.clear(); + this.entitiesById.clear(); + return this.getObjectsToStore(); + } +} diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/NonLazyEntityData.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/NonLazyEntityData.java new file mode 100644 index 00000000..8c285012 --- /dev/null +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/NonLazyEntityData.java @@ -0,0 +1,134 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.repository.root.v2_4; + +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.function.Function; + +import software.xdev.spring.data.eclipse.store.core.IdentitySet; + + +/** + * @param type of entity to store + * @param type of id of the entity to store. Can be {@link Void} if no ID is used. + */ +public class NonLazyEntityData implements EntityData +{ + private final IdentitySet entities; + private ID lastId; + /** + * "Why do you keep the entites at two places? This seems like a waste of space." - Yes, it seems like it is + * duplicated information, but we need to be able to find an entity based on its identity as fast as possible + * ({@link #entities} and also find an entity based on its id {@link #entitiesById}. We could use the BiMaps + * provided by google and apache, but they implemented this also with two seperate lists so there is no benefit in + * using these. + */ + private final HashMap entitiesById; + + private transient Function idGetter; + + public NonLazyEntityData() + { + this.entities = new IdentitySet<>(); + this.entitiesById = new HashMap<>(); + } + + /** + * Accepts {@code null} if no id field is defined + */ + public void setIdGetter(final Function idGetter) + { + this.idGetter = idGetter; + + this.ensureEntitiesAndEntitiesByIdAreTheSameSize(); + } + + private void ensureEntitiesAndEntitiesByIdAreTheSameSize() + { + if(this.idGetter != null && this.entities.size() != this.entitiesById.size()) + { + this.entitiesById.clear(); + this.entities.forEach(entity -> this.entitiesById.put(this.idGetter.apply(entity), entity)); + } + if(this.idGetter == null) + { + this.entitiesById.clear(); + } + } + + public IdentitySet getEntities() + { + return this.entities; + } + + public ID getLastId() + { + return this.lastId; + } + + public HashMap getEntitiesById() + { + return this.entitiesById; + } + + public long getEntityCount() + { + return this.entities.size(); + } + + public void setLastId(final Object lastId) + { + this.lastId = (ID)lastId; + } + + public Collection ensureEntityAndReturnObjectsToStore(final T entityToStore) + { + if(!this.getEntities().contains(entityToStore)) + { + this.entities.add(entityToStore); + if(this.idGetter != null) + { + this.entitiesById.put(this.idGetter.apply(entityToStore), entityToStore); + } + return this.getObjectsToStore(); + } + return List.of(); + } + + public Collection getObjectsToStore() + { + return List.of(this.entities.getInternalMap(), this.entitiesById); + } + + public Collection removeEntityAndReturnObjectsToStore(final T entityToRemove) + { + this.entities.remove(entityToRemove); + if(this.idGetter != null) + { + this.entitiesById.remove(this.idGetter.apply(entityToRemove)); + } + return this.getObjectsToStore(); + } + + public Collection removeAllEntitiesAndReturnObjectsToStore() + { + this.entities.clear(); + this.entitiesById.clear(); + return this.getObjectsToStore(); + } +} diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/RootDataV2_4.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/RootDataV2_4.java index fdd3291a..c8052b5a 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/RootDataV2_4.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/RootDataV2_4.java @@ -27,12 +27,10 @@ public class RootDataV2_4 { private final Map> entityLists; - private final Map> lazyEntityLists; public RootDataV2_4() { this.entityLists = new HashMap<>(); - this.lazyEntityLists = new HashMap<>(); } public Object getEntityListsToStore() @@ -40,10 +38,6 @@ public Object getEntityListsToStore() return this.entityLists; } - public Object getLazyEntityListsToStore() - { - return this.lazyEntityLists; - } public long getEntityTypesCount() { @@ -52,8 +46,7 @@ public long getEntityTypesCount() public long getEntityCount() { - return this.entityLists.values().stream().map(EntityData::getEntityCount).reduce(0L, Long::sum) - + this.lazyEntityLists.values().stream().map(EntityData::getEntityCount).reduce(0L, Long::sum); + return this.entityLists.values().stream().map(EntityData::getEntityCount).reduce(0L, Long::sum); } public EntityData getEntityData(final Class entityClass) @@ -66,28 +59,16 @@ public EntityData getEntityData(final String entityClassName) return (EntityData)this.entityLists.get(entityClassName); } - public EntityData getLazyEntityData(final Class entityClass) - { - return this.getLazyEntityData(this.getEntityName(entityClass)); - } - - public EntityData getLazyEntityData(final String entityClassName) - { - return (EntityData)this.lazyEntityLists.get(entityClassName); - } - public void createNewEntityData(final Class entityClass, final Function idGetter) { - final EntityData - entityData = new EntityData<>(); + final NonLazyEntityData entityData = new NonLazyEntityData<>(); entityData.setIdGetter(idGetter); this.entityLists.put(this.getEntityName(entityClass), entityData); } public void createNewLazyEntityData(final Class entityClass, final Function idGetter) { - final EntityData - entityData = new EntityData<>(); + final LazyEntityData entityData = new LazyEntityData<>(); entityData.setIdGetter(idGetter); this.entityLists.put(this.getEntityName(entityClass), entityData); } diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/EclipseStoreRepositoryFactory.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/EclipseStoreRepositoryFactory.java index c2ac12bd..795f01ee 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/EclipseStoreRepositoryFactory.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/EclipseStoreRepositoryFactory.java @@ -35,8 +35,16 @@ import org.springframework.transaction.PlatformTransactionManager; import software.xdev.spring.data.eclipse.store.repository.EclipseStoreStorage; +import software.xdev.spring.data.eclipse.store.repository.StorageCommunicator; import software.xdev.spring.data.eclipse.store.repository.SupportedChecker; import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository; +import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreCrudRepository; +import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreCustomRepository; +import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreListCrudRepository; +import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreListPagingAndSortingRepository; +import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStorePagingAndSortingRepository; +import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreQueryByExampleExecutor; +import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreRepository; import software.xdev.spring.data.eclipse.store.repository.support.copier.working.RecursiveWorkingCopier; import software.xdev.spring.data.eclipse.store.repository.support.copier.working.WorkingCopier; @@ -68,6 +76,7 @@ public EntityInformation getEntityInformation(@Nonnull final Clas return new PersistentEntityInformation<>(new BasicPersistentEntity<>(TypeInformation.of(domainClass))); } + @SuppressWarnings("deprecation") @Override @Nonnull protected Optional getQueryLookupStrategy( @@ -120,14 +129,25 @@ protected Object getTargetRepository(@Nonnull final RepositoryInformation metada @Nonnull protected Class getRepositoryBaseClass(@Nonnull final RepositoryMetadata metadata) { - final Class domainType = metadata.getDomainType(); - if(domainType.equals(Lazy.class)) + if(isLazyRepository(metadata)) { return LazySimpleEclipseStoreRepository.class; } return SimpleEclipseStoreRepository.class; } + private boolean isLazyRepository(final RepositoryMetadata metadata) + { + final Class repositoryInterface = metadata.getRepositoryInterface(); + return LazyEclipseStoreCrudRepository.class.isAssignableFrom(repositoryInterface) + || LazyEclipseStoreCustomRepository.class.isAssignableFrom(repositoryInterface) + || LazyEclipseStoreListCrudRepository.class.isAssignableFrom(repositoryInterface) + || LazyEclipseStoreListPagingAndSortingRepository.class.isAssignableFrom(repositoryInterface) + || LazyEclipseStorePagingAndSortingRepository.class.isAssignableFrom(repositoryInterface) + || LazyEclipseStoreQueryByExampleExecutor.class.isAssignableFrom(repositoryInterface) + || LazyEclipseStoreRepository.class.isAssignableFrom(repositoryInterface); + } + @Override @Nonnull protected RepositoryInformation getRepositoryInformation( diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/LazySimpleEclipseStoreRepository.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/LazySimpleEclipseStoreRepository.java index e6270354..83ab2464 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/LazySimpleEclipseStoreRepository.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/LazySimpleEclipseStoreRepository.java @@ -15,25 +15,11 @@ */ package software.xdev.spring.data.eclipse.store.repository.support; -import java.util.Collection; -import java.util.List; -import java.util.Optional; -import java.util.function.Function; - -import jakarta.annotation.Nonnull; - -import org.eclipse.serializer.reference.Lazy; -import org.springframework.data.domain.Example; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; -import org.springframework.data.repository.query.FluentQuery; - -import software.xdev.spring.data.eclipse.store.repository.EclipseStoreStorage; +import software.xdev.spring.data.eclipse.store.repository.StorageCommunicator; import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreCrudRepository; import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreListCrudRepository; -import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreListPagingAndSortingRepositoryRepository; -import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStorePagingAndSortingRepositoryRepository; +import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreListPagingAndSortingRepository; +import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStorePagingAndSortingRepository; import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreQueryByExampleExecutor; import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreRepository; import software.xdev.spring.data.eclipse.store.repository.support.copier.working.WorkingCopier; @@ -43,154 +29,28 @@ @SuppressWarnings("java:S119") public class LazySimpleEclipseStoreRepository + extends SimpleEclipseStoreRepository implements LazyEclipseStoreRepository, - LazyEclipseStorePagingAndSortingRepositoryRepository, - LazyEclipseStoreListPagingAndSortingRepositoryRepository, + LazyEclipseStorePagingAndSortingRepository, + LazyEclipseStoreListPagingAndSortingRepository, LazyEclipseStoreCrudRepository, LazyEclipseStoreListCrudRepository, LazyEclipseStoreQueryByExampleExecutor { - private final SimpleEclipseStoreRepository, ID> repository; - public LazySimpleEclipseStoreRepository( - final EclipseStoreStorage storage, - final WorkingCopier> copier, - final Class> domainClass, + final StorageCommunicator storage, + final WorkingCopier copier, + final Class domainClass, final EclipseStoreTransactionManager transactionManager, - final IdManager, ID> idManager - ) - { - this.repository = - new SimpleEclipseStoreRepository<>(storage, copier, domainClass, transactionManager, idManager); - } - - @Override - public void deleteById(@Nonnull final ID id) - { - repository.deleteById(id); - } - - public List saveBulk(final Collection entities) - { - return repository.saveBulk(entities); - } - - @Nonnull - public S save(@Nonnull final S entity) - { - return repository.save(entity); - } - - @Nonnull - public List saveAll(@Nonnull final Iterable entities) - { - return repository.saveAll(entities); - } - - @Override - @Nonnull - public Optional findById(@Nonnull final ID id) - { - return repository.findById(id); - } - - @Override - public boolean existsById(@Nonnull final ID id) - { - return repository.existsById(id); - } - - @Override - @Nonnull - public List findAll() - { - return repository.findAll(); - } - - @Override - @Nonnull - public List findAllById(@Nonnull final Iterable idsToFind) - { - return repository.findAllById(idsToFind); - } - - @Override - public long count() - { - return repository.count(); - } - - public void delete(@Nonnull final T entity) - { - repository.delete(entity); - } - - @Override - public void deleteAllById(final Iterable ids) + final IdManager idManager) { - repository.deleteAllById(ids); - } - - public void deleteAll(final Iterable entities) - { - repository.deleteAll(entities); + super(storage, copier, domainClass, transactionManager, idManager); } @Override - public void deleteAll() - { - repository.deleteAll(); - } - - @Override - @Nonnull - public List findAll(@Nonnull final Sort sort) - { - return repository.findAll(sort); - } - - @Override - @Nonnull - public Page findAll(@Nonnull final Pageable pageable) - { - return repository.findAll(pageable).; - } - - public Optional findOne(final Example example) - { - return repository.findOne(example); - } - - public Iterable findAll(final Example example) - { - return repository.findAll(example); - } - - public Iterable findAll(final Example example, final Sort sort) - { - return repository.findAll(example, sort); - } - - public Page findAll(final Example example, final Pageable pageable) - { - return repository.findAll(example, pageable); - } - - public long count(final Example example) - { - return repository.count(example); - } - - public boolean exists(final Example example) - { - return repository.exists(example); - } - - public R findBy( - final Example example, - final Function, R> queryFunction) + public boolean isLazy() { - return repository.findBy(example, queryFunction); + return true; } } diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/SimpleEclipseStoreRepository.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/SimpleEclipseStoreRepository.java index 267a30a7..d744a436 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/SimpleEclipseStoreRepository.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/SimpleEclipseStoreRepository.java @@ -399,4 +399,9 @@ public R findBy( () -> queryFunction.apply(query) ); } + + public boolean isLazy() + { + return false; + } } diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/reposyncer/RepositorySynchronizer.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/reposyncer/RepositorySynchronizer.java index 8028edad..0e330e2b 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/reposyncer/RepositorySynchronizer.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/reposyncer/RepositorySynchronizer.java @@ -17,7 +17,7 @@ import java.util.Collection; -import software.xdev.spring.data.eclipse.store.repository.root.EntityData; +import software.xdev.spring.data.eclipse.store.repository.root.v2_4.EntityData; /** diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/reposyncer/SimpleRepositorySynchronizer.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/reposyncer/SimpleRepositorySynchronizer.java index b9857158..daf81988 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/reposyncer/SimpleRepositorySynchronizer.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/reposyncer/SimpleRepositorySynchronizer.java @@ -23,18 +23,18 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import software.xdev.spring.data.eclipse.store.repository.root.EntityData; -import software.xdev.spring.data.eclipse.store.repository.root.RootDataV2; +import software.xdev.spring.data.eclipse.store.repository.root.v2_4.EntityData; +import software.xdev.spring.data.eclipse.store.repository.root.v2_4.RootDataV2_4; public class SimpleRepositorySynchronizer implements RepositorySynchronizer { private static final Logger LOG = LoggerFactory.getLogger(SimpleRepositorySynchronizer.class); - private final RootDataV2 root; + private final RootDataV2_4 root; private final HashSet> listsToStore; private final ObjectGraphTraverser buildObjectGraphTraverser; - public SimpleRepositorySynchronizer(final RootDataV2 root) + public SimpleRepositorySynchronizer(final RootDataV2_4 root) { this.root = root; this.listsToStore = new HashSet<>(); @@ -50,7 +50,7 @@ public SimpleRepositorySynchronizer(final RootDataV2 root) return; } final Class objectInGraphClass = (Class)objectInGraph.getClass(); - final EntityData entityDataForCurrentObject = + EntityData entityDataForCurrentObject = this.root.getEntityData(objectInGraphClass); if(entityDataForCurrentObject != null && !entityDataForCurrentObject.getEntities().contains(objectInGraph)) diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/helper/DummyEntityProvider.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/helper/DummyEntityProvider.java index dca8ed1e..7de3af03 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/helper/DummyEntityProvider.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/helper/DummyEntityProvider.java @@ -19,7 +19,8 @@ import java.util.List; import software.xdev.spring.data.eclipse.store.core.EntityProvider; -import software.xdev.spring.data.eclipse.store.repository.root.EntityData; +import software.xdev.spring.data.eclipse.store.repository.root.v2_4.EntityData; +import software.xdev.spring.data.eclipse.store.repository.root.v2_4.NonLazyEntityData; public class DummyEntityProvider extends EntityProvider @@ -27,7 +28,7 @@ public class DummyEntityProvider extends EntityProvider public DummyEntityProvider(final Collection collection) { super(); - final EntityData objects = new EntityData<>(); + final EntityData objects = new NonLazyEntityData<>(); objects.setIdGetter(i -> null); objects.getEntities().addAll(collection); this.addEntityData(objects); diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/LazyTest.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/LazyTest.java index fd1106dc..a342e796 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/LazyTest.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/LazyTest.java @@ -513,21 +513,18 @@ void simpleEntityWithIdLazyWrappedRepository_FindById( void simpleEntityWithIdLazyRepository_FindById(@Autowired final SimpleEntityWithIdLazyRepository repository) { final SimpleEntityWithId objectToStore1 = new SimpleEntityWithId(TestData.DUMMY_STRING); - repository.save(SpringDataEclipseStoreLazy.build(objectToStore1)); + repository.save(objectToStore1); final SimpleEntityWithId objectToStore2 = new SimpleEntityWithId(TestData.DUMMY_STRING); - repository.save(SpringDataEclipseStoreLazy.build(objectToStore2)); + repository.save(objectToStore2); - final List> all = repository.findAll(); + final List all = repository.findAll(); TestUtil.doBeforeAndAfterRestartOfDatastore( this.configuration, () -> { - final Optional> reloadedObject = - repository.findById(all.get(0).get().getId()); + final Optional reloadedObject = + repository.findById(all.get(0).getId()); Assertions.assertTrue(reloadedObject.isPresent()); - Assertions.assertFalse(reloadedObject.get().isLoaded()); - Assertions.assertEquals(objectToStore1, reloadedObject.get().get()); - Assertions.assertTrue(reloadedObject.get().isLoaded()); } ); } From cd26674e1a9924b12d62ef58545344a0fbdcc6b8 Mon Sep 17 00:00:00 2001 From: JohannesRabauer Date: Fri, 6 Dec 2024 13:00:11 +0100 Subject: [PATCH 38/54] Implemented LazyEntitiyData as Lazy --- .../eclipse/store/core/EntityProvider.java | 8 +- .../repository/root/v2_4/EntityData.java | 9 ++- .../repository/root/v2_4/LazyEntityData.java | 76 +++++++++++++++---- .../root/v2_4/NonLazyEntityData.java | 47 +++++++++--- .../SimpleRepositorySynchronizer.java | 2 +- .../store/helper/DummyEntityProvider.java | 2 +- 6 files changed, 108 insertions(+), 36 deletions(-) diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/core/EntityProvider.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/core/EntityProvider.java index f0dcb709..0fdfd649 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/core/EntityProvider.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/core/EntityProvider.java @@ -18,8 +18,8 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.Objects; import java.util.Optional; -import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -38,7 +38,7 @@ public void addEntityData(final EntityData entityData) public Stream stream() { - return this.entityDataList.stream().map(EntityData::getEntities).flatMap(Set::stream); + return this.entityDataList.stream().flatMap(EntityData::getEntitiesAsStream); } public Collection toCollection() @@ -61,8 +61,8 @@ public Optional findAnyEntityWithId(final ID id) { return (Optional)this.entityDataList .stream() - .map(entityData -> entityData.getEntitiesById().get(id)) - .filter(e -> e != null) + .map(entityData -> entityData.getEntityById(id)) + .filter(Objects::nonNull) .findAny(); } } diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/EntityData.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/EntityData.java index b61059fc..f388f167 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/EntityData.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/EntityData.java @@ -18,6 +18,7 @@ import java.util.Collection; import java.util.HashMap; import java.util.function.Function; +import java.util.stream.Stream; import software.xdev.spring.data.eclipse.store.core.IdentitySet; @@ -34,11 +35,11 @@ public interface EntityData */ void setIdGetter(final Function idGetter); - IdentitySet getEntities(); + Stream getEntitiesAsStream(); - ID getLastId(); + boolean containsEntity(final T entity); - HashMap getEntitiesById(); + ID getLastId(); long getEntityCount(); @@ -51,4 +52,6 @@ public interface EntityData Collection removeEntityAndReturnObjectsToStore(final T entityToRemove); Collection removeAllEntitiesAndReturnObjectsToStore(); + + T getEntityById(ID id); } diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/LazyEntityData.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/LazyEntityData.java index 3ac3104e..4918a860 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/LazyEntityData.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/LazyEntityData.java @@ -19,8 +19,13 @@ import java.util.HashMap; import java.util.List; import java.util.function.Function; +import java.util.stream.Stream; + +import org.eclipse.serializer.reference.Lazy; +import org.eclipse.serializer.reference.Referencing; import software.xdev.spring.data.eclipse.store.core.IdentitySet; +import software.xdev.spring.data.eclipse.store.repository.lazy.SpringDataEclipseStoreLazy; /** @@ -29,7 +34,7 @@ */ public class LazyEntityData implements EntityData { - private final IdentitySet entities; + private final IdentitySet> entities; private ID lastId; /** * "Why do you keep the entites at two places? This seems like a waste of space." - Yes, it seems like it is @@ -38,7 +43,7 @@ public class LazyEntityData implements EntityData * provided by google and apache, but they implemented this also with two seperate lists so there is no benefit in * using these. */ - private final HashMap entitiesById; + private final HashMap> entitiesById; private transient Function idGetter; @@ -51,6 +56,7 @@ public LazyEntityData() /** * Accepts {@code null} if no id field is defined */ + @Override public void setIdGetter(final Function idGetter) { this.idGetter = idGetter; @@ -58,12 +64,34 @@ public void setIdGetter(final Function idGetter) this.ensureEntitiesAndEntitiesByIdAreTheSameSize(); } + @Override + public Stream getEntitiesAsStream() + { + return this.entities.stream().map(Referencing::get); + } + + @Override + public boolean containsEntity(final T entity) + { + if(this.idGetter == null) + { + return this.entities + .stream() + .anyMatch(lazyEntity -> lazyEntity.get() == entity); + } + else + { + final ID id = this.idGetter.apply(entity); + return this.entitiesById.containsKey(id); + } + } + private void ensureEntitiesAndEntitiesByIdAreTheSameSize() { if(this.idGetter != null && this.entities.size() != this.entitiesById.size()) { this.entitiesById.clear(); - this.entities.forEach(entity -> this.entitiesById.put(this.idGetter.apply(entity), entity)); + this.entities.forEach(entity -> this.entitiesById.put(this.idGetter.apply(entity.get()), entity)); } if(this.idGetter == null) { @@ -71,60 +99,76 @@ private void ensureEntitiesAndEntitiesByIdAreTheSameSize() } } - public IdentitySet getEntities() - { - return this.entities; - } - + @Override public ID getLastId() { return this.lastId; } - public HashMap getEntitiesById() + @Override + public T getEntityById(final ID id) { - return this.entitiesById; + final Lazy lazyEntity = this.entitiesById.get(id); + return lazyEntity == null ? null : lazyEntity.get(); } + @Override public long getEntityCount() { return this.entities.size(); } + @Override public void setLastId(final Object lastId) { this.lastId = (ID)lastId; } + @Override public Collection ensureEntityAndReturnObjectsToStore(final T entityToStore) { - if(!this.getEntities().contains(entityToStore)) + if(!this.containsEntity(entityToStore)) { - this.entities.add(entityToStore); + final SpringDataEclipseStoreLazy.Default newLazyEntity = + SpringDataEclipseStoreLazy.build(entityToStore); + this.entities.add(newLazyEntity); if(this.idGetter != null) { - this.entitiesById.put(this.idGetter.apply(entityToStore), entityToStore); + this.entitiesById.put(this.idGetter.apply(entityToStore), newLazyEntity); } return this.getObjectsToStore(); } return List.of(); } + @Override public Collection getObjectsToStore() { return List.of(this.entities.getInternalMap(), this.entitiesById); } + @Override public Collection removeEntityAndReturnObjectsToStore(final T entityToRemove) { - this.entities.remove(entityToRemove); - if(this.idGetter != null) + if(this.idGetter == null) + { + this.entities + .stream() + .filter(entity -> entity.get() == entityToRemove) + .findAny() + .ifPresent(this.entities::remove); + } + else { - this.entitiesById.remove(this.idGetter.apply(entityToRemove)); + final ID id = this.idGetter.apply(entityToRemove); + final Lazy lazyReference = this.entitiesById.get(id); + this.entities.remove(lazyReference); + this.entitiesById.remove(id); } return this.getObjectsToStore(); } + @Override public Collection removeAllEntitiesAndReturnObjectsToStore() { this.entities.clear(); diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/NonLazyEntityData.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/NonLazyEntityData.java index 8c285012..78cb6de2 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/NonLazyEntityData.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/NonLazyEntityData.java @@ -19,6 +19,7 @@ import java.util.HashMap; import java.util.List; import java.util.function.Function; +import java.util.stream.Stream; import software.xdev.spring.data.eclipse.store.core.IdentitySet; @@ -51,6 +52,7 @@ public NonLazyEntityData() /** * Accepts {@code null} if no id field is defined */ + @Override public void setIdGetter(final Function idGetter) { this.idGetter = idGetter; @@ -58,6 +60,26 @@ public void setIdGetter(final Function idGetter) this.ensureEntitiesAndEntitiesByIdAreTheSameSize(); } + @Override + public Stream getEntitiesAsStream() + { + return this.entities.stream(); + } + + @Override + public boolean containsEntity(final T entity) + { + if(this.idGetter == null) + { + return this.entities.contains(entity); + } + else + { + final ID id = this.idGetter.apply(entity); + return this.entitiesById.containsKey(id); + } + } + private void ensureEntitiesAndEntitiesByIdAreTheSameSize() { if(this.idGetter != null && this.entities.size() != this.entitiesById.size()) @@ -71,34 +93,28 @@ private void ensureEntitiesAndEntitiesByIdAreTheSameSize() } } - public IdentitySet getEntities() - { - return this.entities; - } - + @Override public ID getLastId() { return this.lastId; } - public HashMap getEntitiesById() - { - return this.entitiesById; - } - + @Override public long getEntityCount() { return this.entities.size(); } + @Override public void setLastId(final Object lastId) { this.lastId = (ID)lastId; } + @Override public Collection ensureEntityAndReturnObjectsToStore(final T entityToStore) { - if(!this.getEntities().contains(entityToStore)) + if(!this.containsEntity(entityToStore)) { this.entities.add(entityToStore); if(this.idGetter != null) @@ -110,11 +126,19 @@ public Collection ensureEntityAndReturnObjectsToStore(final T entityToSt return List.of(); } + @Override public Collection getObjectsToStore() { return List.of(this.entities.getInternalMap(), this.entitiesById); } + @Override + public T getEntityById(final ID id) + { + return this.entitiesById.get(id); + } + + @Override public Collection removeEntityAndReturnObjectsToStore(final T entityToRemove) { this.entities.remove(entityToRemove); @@ -125,6 +149,7 @@ public Collection removeEntityAndReturnObjectsToStore(final T entityToRe return this.getObjectsToStore(); } + @Override public Collection removeAllEntitiesAndReturnObjectsToStore() { this.entities.clear(); diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/reposyncer/SimpleRepositorySynchronizer.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/reposyncer/SimpleRepositorySynchronizer.java index daf81988..693ca96d 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/reposyncer/SimpleRepositorySynchronizer.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/reposyncer/SimpleRepositorySynchronizer.java @@ -53,7 +53,7 @@ public SimpleRepositorySynchronizer(final RootDataV2_4 root) EntityData entityDataForCurrentObject = this.root.getEntityData(objectInGraphClass); if(entityDataForCurrentObject != null - && !entityDataForCurrentObject.getEntities().contains(objectInGraph)) + && !entityDataForCurrentObject.containsEntity(objectInGraph)) { entityDataForCurrentObject.ensureEntityAndReturnObjectsToStore(objectInGraph); this.listsToStore.add(entityDataForCurrentObject); diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/helper/DummyEntityProvider.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/helper/DummyEntityProvider.java index 7de3af03..3dab0346 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/helper/DummyEntityProvider.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/helper/DummyEntityProvider.java @@ -30,7 +30,7 @@ public DummyEntityProvider(final Collection collection) super(); final EntityData objects = new NonLazyEntityData<>(); objects.setIdGetter(i -> null); - objects.getEntities().addAll(collection); + collection.forEach(objects::ensureEntityAndReturnObjectsToStore); this.addEntityData(objects); } From e41b153764174478e2cf00aec455cd7f07f63a88 Mon Sep 17 00:00:00 2001 From: XDEV Renovate Bot Date: Sun, 8 Dec 2024 02:43:20 +0000 Subject: [PATCH 39/54] Update dependency org.apache.maven.plugins:maven-javadoc-plugin to v3.11.2 --- spring-data-eclipse-store/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-data-eclipse-store/pom.xml b/spring-data-eclipse-store/pom.xml index 1b86cd82..dbc680b9 100644 --- a/spring-data-eclipse-store/pom.xml +++ b/spring-data-eclipse-store/pom.xml @@ -323,7 +323,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.11.1 + 3.11.2 attach-javadocs From 1d2bd3a3dc4b9687286702de035e8b3a9dfe55bd Mon Sep 17 00:00:00 2001 From: JohannesRabauer Date: Mon, 9 Dec 2024 08:42:21 +0100 Subject: [PATCH 40/54] Fix - Nonlazy functionality --- .../store/repository/EclipseStoreStorage.java | 7 +-- .../store/repository/root/VersionedRoot.java | 11 ++++- .../scripts/v2_0_0_InitializeVersioning.java | 9 ++-- .../update/scripts/v2_4_0_InitializeLazy.java | 25 ++++++----- .../repository/root/v2_4/EntityData.java | 3 +- .../repository/root/v2_4/LazyEntityData.java | 13 +++--- .../root/v2_4/NonLazyEntityData.java | 31 +++++++------ .../repository/root/v2_4/RootDataV2_4.java | 7 +-- .../tests/migration/MigrationTest.java | 45 +++++++++++++++++-- 9 files changed, 106 insertions(+), 45 deletions(-) diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreStorage.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreStorage.java index 67e3c1d5..d74cc08e 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreStorage.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreStorage.java @@ -209,13 +209,14 @@ private void ensureEntityData() public void createNewEntityData(final Class entityClass, final VersionedRoot root) { final IdManager idManager = this.ensureIdManager(entityClass); - if(this.entityClassToRepository.get(entityClass).isLazy()) + final SimpleEclipseStoreRepository repository = this.entityClassToRepository.get(entityClass); + if(repository != null && repository.isLazy()) { - root.getCurrentRootData().createNewLazyEntityData(entityClass, idManager::getId); + root.getCurrentRootData().createNewLazyEntityData(entityClass, idManager); } else { - root.getCurrentRootData().createNewEntityData(entityClass, idManager::getId); + root.getCurrentRootData().createNewEntityData(entityClass, idManager); } } diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/VersionedRoot.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/VersionedRoot.java index 1af617e6..fd435a55 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/VersionedRoot.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/VersionedRoot.java @@ -61,6 +61,15 @@ public Root getRootDataV1() return this.rootDataV1; } + /** + * @deprecated and is only used in tests + */ + @Deprecated + public void setRootDataV2(final RootDataV2 rootDataV2) + { + this.rootDataV2 = rootDataV2; + } + public RootDataV2 getRootDataV2() { return this.rootDataV2; @@ -69,7 +78,7 @@ public RootDataV2 getRootDataV2() @SuppressWarnings("checkstyle:MethodName") public RootDataV2_4 getRootDataV2_4() { - return rootDataV2_4; + return this.rootDataV2_4; } public void clearOldRootData() diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/update/scripts/v2_0_0_InitializeVersioning.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/update/scripts/v2_0_0_InitializeVersioning.java index 2aabbab4..73eba636 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/update/scripts/v2_0_0_InitializeVersioning.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/update/scripts/v2_0_0_InitializeVersioning.java @@ -20,9 +20,9 @@ import software.xdev.micromigration.eclipsestore.MigrationEmbeddedStorageManager; import software.xdev.micromigration.scripts.Context; -import software.xdev.spring.data.eclipse.store.repository.root.EntityData; import software.xdev.spring.data.eclipse.store.repository.root.RootDataV2; import software.xdev.spring.data.eclipse.store.repository.root.VersionedRoot; +import software.xdev.spring.data.eclipse.store.repository.root.v2_4.EntityData; /** @@ -44,10 +44,12 @@ public void loggedMigrate(final Context { - final EntityData entityData = versionedRoot.getRootDataV2().getEntityData(entityName); + final EntityData entityData = + versionedRoot.getCurrentRootData().getEntityData(entityName); if(entityData == null) { LOG.warn("Dropping entities {} because there is no repository in the new root.", entityName); + return; } entities.forEach(entity -> entityData.ensureEntityAndReturnObjectsToStore(entity)); context.getStorageManager().getNativeStorageManager().storeAll(entityData.getObjectsToStore()); @@ -57,7 +59,8 @@ public void loggedMigrate(final Context { - final EntityData entityData = versionedRoot.getRootDataV2().getEntityData(entityName); + final software.xdev.spring.data.eclipse.store.repository.root.EntityData entityData = + versionedRoot.getRootDataV2().getEntityData(entityName); entityData.setLastId(lastId); context.getStorageManager().store(entityData); LOG.info("Migrated last id of entities {}.", entityName); diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/update/scripts/v2_4_0_InitializeLazy.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/update/scripts/v2_4_0_InitializeLazy.java index 17eee7d6..c34032e2 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/update/scripts/v2_4_0_InitializeLazy.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/update/scripts/v2_4_0_InitializeLazy.java @@ -40,17 +40,20 @@ public class v2_4_0_InitializeLazy extends LoggingUpdateScript public void loggedMigrate(final Context context) { final VersionedRoot versionedRoot = context.getMigratingObject(); - versionedRoot.getRootDataV2().getEntityListsToStore().forEach( - (entityName, entities) -> - { - final software.xdev.spring.data.eclipse.store.repository.root.v2_4.EntityData - newEntityData = versionedRoot.getRootDataV2_4().getEntityData(entityName); - entities.getEntities().forEach(newEntityData::ensureEntityAndReturnObjectsToStore); - newEntityData.setLastId(entities.getLastId()); - context.getStorageManager().getNativeStorageManager().storeAll(newEntityData.getObjectsToStore()); - LOG.info("Migrated entities {}.", entityName); - } - ); + if(versionedRoot.getRootDataV2() != null) + { + versionedRoot.getRootDataV2().getEntityListsToStore().forEach( + (entityName, entities) -> + { + final software.xdev.spring.data.eclipse.store.repository.root.v2_4.EntityData + newEntityData = versionedRoot.getCurrentRootData().getEntityData(entityName); + entities.getEntities().forEach(newEntityData::ensureEntityAndReturnObjectsToStore); + newEntityData.setLastId(entities.getLastId()); + context.getStorageManager().getNativeStorageManager().storeAll(newEntityData.getObjectsToStore()); + LOG.info("Migrated entities {}.", entityName); + } + ); + } versionedRoot.clearOldRootData(); context.getStorageManager().store(versionedRoot); } diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/EntityData.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/EntityData.java index f388f167..ad8310de 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/EntityData.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/EntityData.java @@ -21,6 +21,7 @@ import java.util.stream.Stream; import software.xdev.spring.data.eclipse.store.core.IdentitySet; +import software.xdev.spring.data.eclipse.store.repository.support.id.IdGetter; /** @@ -33,7 +34,7 @@ public interface EntityData /** * Accepts {@code null} if no id field is defined */ - void setIdGetter(final Function idGetter); + void setIdGetter(final IdGetter idGetter); Stream getEntitiesAsStream(); diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/LazyEntityData.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/LazyEntityData.java index 4918a860..87a348af 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/LazyEntityData.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/LazyEntityData.java @@ -26,6 +26,7 @@ import software.xdev.spring.data.eclipse.store.core.IdentitySet; import software.xdev.spring.data.eclipse.store.repository.lazy.SpringDataEclipseStoreLazy; +import software.xdev.spring.data.eclipse.store.repository.support.id.IdGetter; /** @@ -45,7 +46,7 @@ public class LazyEntityData implements EntityData */ private final HashMap> entitiesById; - private transient Function idGetter; + private transient IdGetter idGetter; public LazyEntityData() { @@ -57,7 +58,7 @@ public LazyEntityData() * Accepts {@code null} if no id field is defined */ @Override - public void setIdGetter(final Function idGetter) + public void setIdGetter(final IdGetter idGetter) { this.idGetter = idGetter; @@ -81,7 +82,7 @@ public boolean containsEntity(final T entity) } else { - final ID id = this.idGetter.apply(entity); + final ID id = this.idGetter.getId(entity); return this.entitiesById.containsKey(id); } } @@ -91,7 +92,7 @@ private void ensureEntitiesAndEntitiesByIdAreTheSameSize() if(this.idGetter != null && this.entities.size() != this.entitiesById.size()) { this.entitiesById.clear(); - this.entities.forEach(entity -> this.entitiesById.put(this.idGetter.apply(entity.get()), entity)); + this.entities.forEach(entity -> this.entitiesById.put(this.idGetter.getId(entity.get()), entity)); } if(this.idGetter == null) { @@ -134,7 +135,7 @@ public Collection ensureEntityAndReturnObjectsToStore(final T entityToSt this.entities.add(newLazyEntity); if(this.idGetter != null) { - this.entitiesById.put(this.idGetter.apply(entityToStore), newLazyEntity); + this.entitiesById.put(this.idGetter.getId(entityToStore), newLazyEntity); } return this.getObjectsToStore(); } @@ -160,7 +161,7 @@ public Collection removeEntityAndReturnObjectsToStore(final T entityToRe } else { - final ID id = this.idGetter.apply(entityToRemove); + final ID id = this.idGetter.getId(entityToRemove); final Lazy lazyReference = this.entitiesById.get(id); this.entities.remove(lazyReference); this.entitiesById.remove(id); diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/NonLazyEntityData.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/NonLazyEntityData.java index 78cb6de2..cbcf2b2b 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/NonLazyEntityData.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/NonLazyEntityData.java @@ -22,6 +22,7 @@ import java.util.stream.Stream; import software.xdev.spring.data.eclipse.store.core.IdentitySet; +import software.xdev.spring.data.eclipse.store.repository.support.id.IdGetter; /** @@ -41,7 +42,7 @@ public class NonLazyEntityData implements EntityData */ private final HashMap entitiesById; - private transient Function idGetter; + private transient IdGetter idGetter; public NonLazyEntityData() { @@ -53,7 +54,7 @@ public NonLazyEntityData() * Accepts {@code null} if no id field is defined */ @Override - public void setIdGetter(final Function idGetter) + public void setIdGetter(final IdGetter idGetter) { this.idGetter = idGetter; @@ -75,8 +76,9 @@ public boolean containsEntity(final T entity) } else { - final ID id = this.idGetter.apply(entity); - return this.entitiesById.containsKey(id); + final ID id = this.idGetter.getId(entity); + final T existingEntity = this.entitiesById.get(id); + return existingEntity != null && existingEntity == entity; } } @@ -85,7 +87,7 @@ private void ensureEntitiesAndEntitiesByIdAreTheSameSize() if(this.idGetter != null && this.entities.size() != this.entitiesById.size()) { this.entitiesById.clear(); - this.entities.forEach(entity -> this.entitiesById.put(this.idGetter.apply(entity), entity)); + this.entities.forEach(entity -> this.entitiesById.put(this.idGetter.getId(entity), entity)); } if(this.idGetter == null) { @@ -114,16 +116,17 @@ public void setLastId(final Object lastId) @Override public Collection ensureEntityAndReturnObjectsToStore(final T entityToStore) { - if(!this.containsEntity(entityToStore)) + Collection listToSave = List.of(); + if(this.entities.add(entityToStore)) { - this.entities.add(entityToStore); - if(this.idGetter != null) - { - this.entitiesById.put(this.idGetter.apply(entityToStore), entityToStore); - } - return this.getObjectsToStore(); + listToSave = this.getObjectsToStore(); } - return List.of(); + if(this.idGetter != null && this.entitiesById.get(this.idGetter.getId(entityToStore)) != entityToStore) + { + this.entitiesById.put(this.idGetter.getId(entityToStore), entityToStore); + listToSave = this.getObjectsToStore(); + } + return listToSave; } @Override @@ -144,7 +147,7 @@ public Collection removeEntityAndReturnObjectsToStore(final T entityToRe this.entities.remove(entityToRemove); if(this.idGetter != null) { - this.entitiesById.remove(this.idGetter.apply(entityToRemove)); + this.entitiesById.remove(this.idGetter.getId(entityToRemove)); } return this.getObjectsToStore(); } diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/RootDataV2_4.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/RootDataV2_4.java index c8052b5a..07697650 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/RootDataV2_4.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/RootDataV2_4.java @@ -17,7 +17,8 @@ import java.util.HashMap; import java.util.Map; -import java.util.function.Function; + +import software.xdev.spring.data.eclipse.store.repository.support.id.IdGetter; /** @@ -59,14 +60,14 @@ public EntityData getEntityData(final String entityClassName) return (EntityData)this.entityLists.get(entityClassName); } - public void createNewEntityData(final Class entityClass, final Function idGetter) + public void createNewEntityData(final Class entityClass, final IdGetter idGetter) { final NonLazyEntityData entityData = new NonLazyEntityData<>(); entityData.setIdGetter(idGetter); this.entityLists.put(this.getEntityName(entityClass), entityData); } - public void createNewLazyEntityData(final Class entityClass, final Function idGetter) + public void createNewLazyEntityData(final Class entityClass, final IdGetter idGetter) { final LazyEntityData entityData = new LazyEntityData<>(); entityData.setIdGetter(idGetter); diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/migration/MigrationTest.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/migration/MigrationTest.java index 0a70c1f3..9d1a5c47 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/migration/MigrationTest.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/migration/MigrationTest.java @@ -30,12 +30,16 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.util.FileSystemUtils; +import software.xdev.micromigration.version.MigrationVersion; import software.xdev.spring.data.eclipse.store.helper.TestData; import software.xdev.spring.data.eclipse.store.helper.TestUtil; import software.xdev.spring.data.eclipse.store.integration.isolated.IsolatedTestAnnotations; import software.xdev.spring.data.eclipse.store.repository.Root; +import software.xdev.spring.data.eclipse.store.repository.root.RootDataV2; +import software.xdev.spring.data.eclipse.store.repository.root.VersionedRoot; +@SuppressWarnings({"deprecation", "checkstyle:MethodName"}) @IsolatedTestAnnotations @ContextConfiguration(classes = {MigrationTestConfiguration.class}) class MigrationTest @@ -53,9 +57,9 @@ public MigrationTest(final MigrationTestConfiguration configuration, final UserR } @Test - void simpleMigrateFromV000ToV200() throws IOException + void simpleMigrateFromV0_0_0ToNewest() throws IOException { - this.initOldData(); + this.initV1_0_0Data(); TestUtil.doBeforeAndAfterRestartOfDatastore( this.configuration, () -> { @@ -66,7 +70,21 @@ void simpleMigrateFromV000ToV200() throws IOException ); } - private void initOldData() throws IOException + @Test + void simpleMigrateFromV2_0_0ToNewest() throws IOException + { + this.initV2_0_0Data(); + TestUtil.doBeforeAndAfterRestartOfDatastore( + this.configuration, + () -> { + final List foundUsers = this.userRepository.findAll(); + Assertions.assertEquals(1, foundUsers.size()); + Assertions.assertEquals(TEST_USER, foundUsers.get(0)); + } + ); + } + + private void initV1_0_0Data() throws IOException { // Delete already created data this.configuration.getStorageInstance().stop(); @@ -84,4 +102,25 @@ private void initOldData() throws IOException storageManager.storeRoot(); } } + + private void initV2_0_0Data() throws IOException + { + // Delete already created data + this.configuration.getStorageInstance().stop(); + FileSystemUtils.deleteRecursively(Path.of(this.configuration.getStorageDirectory())); + + // Init old data + try(final EmbeddedStorageManager storageManager = + Foundation(Storage.Configuration(Storage.FileProvider(Path.of(this.configuration.getStorageDirectory())))) + .start()) + { + final VersionedRoot oldRoot = new VersionedRoot(); + oldRoot.setRootDataV2(new RootDataV2()); + oldRoot.getRootDataV2().createNewEntityData(User.class, e -> null); + oldRoot.getRootDataV2().getEntityData(User.class).ensureEntityAndReturnObjectsToStore(TEST_USER); + oldRoot.setVersion(new MigrationVersion(2, 0, 0)); + storageManager.setRoot(oldRoot); + storageManager.storeRoot(); + } + } } From aff511dff21a663a46903a63deca03edd88c8c3e Mon Sep 17 00:00:00 2001 From: JohannesRabauer Date: Mon, 9 Dec 2024 08:52:20 +0100 Subject: [PATCH 41/54] Simple Lazy Tests working --- .../store/integration/isolated/tests/lazy/LazyTest.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/LazyTest.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/LazyTest.java index a342e796..b0b74e89 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/LazyTest.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/LazyTest.java @@ -475,7 +475,8 @@ void simpleEntityWithIdLazyWrappedRepository_PersistetAfterRestart( () -> { Assertions.assertEquals(1, repository.findAll().size()); final Lazy reloadedObject = repository.findAll().get(0); - Assertions.assertEquals(objectToStore, reloadedObject.get()); + Assertions.assertEquals(objectToStore.getId(), reloadedObject.get().getId()); + Assertions.assertEquals(objectToStore.getName(), reloadedObject.get().getName()); } ); } @@ -493,7 +494,8 @@ void simpleEntityWithIdLazyWrappedRepository_OnlyLoadOnDemand( final Lazy reloadedObject = repository.findAll().get(0); Assertions.assertFalse(reloadedObject.isLoaded()); - Assertions.assertEquals(objectToStore, reloadedObject.get()); + Assertions.assertEquals(objectToStore.getId(), reloadedObject.get().getId()); + Assertions.assertEquals(objectToStore.getName(), reloadedObject.get().getName()); Assertions.assertTrue(reloadedObject.isLoaded()); } From f4b4e4e22af8714f86bf01442a3e28a8538405a0 Mon Sep 17 00:00:00 2001 From: JohannesRabauer Date: Mon, 9 Dec 2024 09:02:21 +0100 Subject: [PATCH 42/54] Minor fixes and refactoring --- .../eclipse/store/jpa/integration/JpaImportExplicitTest.java | 2 +- .../data/eclipse/store/jpa/integration/JpaImportTest.java | 2 +- .../store/repository/support/concurrency/ValueOperation.java | 4 ++-- .../store/repository/support/concurrency/VoidOperation.java | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/JpaImportExplicitTest.java b/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/JpaImportExplicitTest.java index 112bf8cf..70e452fb 100644 --- a/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/JpaImportExplicitTest.java +++ b/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/JpaImportExplicitTest.java @@ -63,7 +63,7 @@ void testEclipseStoreImportExplicitNoComponent() this.configuration.getStorageInstance().stop(); Assertions.assertEquals( 1, - this.configuration.getStorageInstance().getNonLazyCommunicator().getEntityCount(PersonToTestInJpa.class), + this.configuration.getStorageInstance().getEntityCount(PersonToTestInJpa.class), "After restart the imported entities are not there anymore."); } } diff --git a/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/JpaImportTest.java b/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/JpaImportTest.java index 50c504e0..b1a3bf03 100644 --- a/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/JpaImportTest.java +++ b/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/JpaImportTest.java @@ -72,7 +72,7 @@ void testEclipseStoreImport(@Autowired final EclipseStoreDataImporterComponent e this.configuration.getStorageInstance().stop(); Assertions.assertEquals( 1, - this.configuration.getStorageInstance().getNonLazyCommunicator().getEntityCount(PersonToTestInJpa.class), + this.configuration.getStorageInstance().getEntityCount(PersonToTestInJpa.class), "After restart the imported entities are not there anymore."); } diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/concurrency/ValueOperation.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/concurrency/ValueOperation.java index 8bb369f0..f9296950 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/concurrency/ValueOperation.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/concurrency/ValueOperation.java @@ -16,7 +16,7 @@ package software.xdev.spring.data.eclipse.store.repository.support.concurrency; /** - * Operation with a return value, used by {@link ReentrantJavaReadWriteLock} and {@link ReadWriteLockedStriped}. + * Operation with a return value, used by {@link ReentrantJavaReadWriteLock}. * * @param T the return type */ @@ -28,5 +28,5 @@ public interface ValueOperation * * @return the result of the operation */ - public T execute(); + T execute(); } diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/concurrency/VoidOperation.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/concurrency/VoidOperation.java index 829c5ab8..139743eb 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/concurrency/VoidOperation.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/concurrency/VoidOperation.java @@ -16,7 +16,7 @@ package software.xdev.spring.data.eclipse.store.repository.support.concurrency; /** - * Operation with no return value, used by {@link ReentrantJavaReadWriteLock} and {@link ReadWriteLockedStriped}. + * Operation with no return value, used by {@link ReentrantJavaReadWriteLock}. */ @FunctionalInterface public interface VoidOperation @@ -24,5 +24,5 @@ public interface VoidOperation /** * Execute an arbitrary operation */ - public void execute(); + void execute(); } From 6930b5aa20f7cb3a53ede3a1ece4c63189438820 Mon Sep 17 00:00:00 2001 From: JohannesRabauer Date: Mon, 9 Dec 2024 09:18:22 +0100 Subject: [PATCH 43/54] Isolated real life example tests --- .../tests/real/life/examples}/Article.java | 2 +- .../real/life/examples}/ArticleGroup.java | 2 +- .../tests/real/life/examples}/Invoice.java | 2 +- .../life/examples}/InvoiceRepository.java | 2 +- .../tests/real/life/examples}/Position.java | 2 +- .../life/examples}/PositionRepository.java | 2 +- .../life/examples/RealLifeExamplesTest.java} | 28 +++++----- .../RealLifeExamplesTestConfiguration.java | 53 +++++++++++++++++++ .../real/life/examples/RealLifeTests.java | 38 +++++++++++++ .../tests/real/life/examples}/Warehouse.java | 2 +- 10 files changed, 111 insertions(+), 22 deletions(-) rename spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/{shared/repositories/real/life/example => isolated/tests/real/life/examples}/Article.java (94%) rename spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/{shared/repositories/real/life/example => isolated/tests/real/life/examples}/ArticleGroup.java (89%) rename spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/{shared/repositories/real/life/example => isolated/tests/real/life/examples}/Invoice.java (90%) rename spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/{shared/repositories/real/life/example => isolated/tests/real/life/examples}/InvoiceRepository.java (88%) rename spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/{shared/repositories/real/life/example => isolated/tests/real/life/examples}/Position.java (93%) rename spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/{shared/repositories/real/life/example => isolated/tests/real/life/examples}/PositionRepository.java (88%) rename spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/{shared/tests/RealLifeTests.java => isolated/tests/real/life/examples/RealLifeExamplesTest.java} (89%) create mode 100644 spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/RealLifeExamplesTestConfiguration.java create mode 100644 spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/RealLifeTests.java rename spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/{shared/repositories/real/life/example => isolated/tests/real/life/examples}/Warehouse.java (91%) diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/real/life/example/Article.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/Article.java similarity index 94% rename from spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/real/life/example/Article.java rename to spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/Article.java index 21b89654..2f1e12f5 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/real/life/example/Article.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/Article.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package software.xdev.spring.data.eclipse.store.integration.shared.repositories.real.life.example; +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples; import java.util.ArrayList; import java.util.Collections; diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/real/life/example/ArticleGroup.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/ArticleGroup.java similarity index 89% rename from spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/real/life/example/ArticleGroup.java rename to spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/ArticleGroup.java index dc73ba6d..f21a1eb3 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/real/life/example/ArticleGroup.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/ArticleGroup.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package software.xdev.spring.data.eclipse.store.integration.shared.repositories.real.life.example; +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples; public class ArticleGroup { diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/real/life/example/Invoice.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/Invoice.java similarity index 90% rename from spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/real/life/example/Invoice.java rename to spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/Invoice.java index 868061ee..5fed9d10 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/real/life/example/Invoice.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/Invoice.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package software.xdev.spring.data.eclipse.store.integration.shared.repositories.real.life.example; +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples; import java.util.List; diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/real/life/example/InvoiceRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/InvoiceRepository.java similarity index 88% rename from spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/real/life/example/InvoiceRepository.java rename to spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/InvoiceRepository.java index baa35843..07186e01 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/real/life/example/InvoiceRepository.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/InvoiceRepository.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package software.xdev.spring.data.eclipse.store.integration.shared.repositories.real.life.example; +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples; import org.springframework.data.repository.CrudRepository; diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/real/life/example/Position.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/Position.java similarity index 93% rename from spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/real/life/example/Position.java rename to spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/Position.java index b0894b12..78702d16 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/real/life/example/Position.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/Position.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package software.xdev.spring.data.eclipse.store.integration.shared.repositories.real.life.example; +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples; import java.util.List; import java.util.Optional; diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/real/life/example/PositionRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/PositionRepository.java similarity index 88% rename from spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/real/life/example/PositionRepository.java rename to spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/PositionRepository.java index 883c4a42..4c545ba9 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/real/life/example/PositionRepository.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/PositionRepository.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package software.xdev.spring.data.eclipse.store.integration.shared.repositories.real.life.example; +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples; import org.springframework.data.repository.ListCrudRepository; diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/tests/RealLifeTests.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/RealLifeExamplesTest.java similarity index 89% rename from spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/tests/RealLifeTests.java rename to spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/RealLifeExamplesTest.java index 46ee7c6b..9b263c2c 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/tests/RealLifeTests.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/RealLifeExamplesTest.java @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package software.xdev.spring.data.eclipse.store.integration.shared.tests; +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples; -import static software.xdev.spring.data.eclipse.store.integration.shared.repositories.real.life.example.Position.getPositionWithArticleWithName; +import static software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.Position.getPositionWithArticleWithName; import java.util.ArrayList; import java.util.Arrays; @@ -25,22 +25,15 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; import software.xdev.spring.data.eclipse.store.helper.TestUtil; -import software.xdev.spring.data.eclipse.store.integration.shared.DefaultTestAnnotations; -import software.xdev.spring.data.eclipse.store.integration.shared.SharedTestConfiguration; -import software.xdev.spring.data.eclipse.store.integration.shared.repositories.real.life.example.Article; -import software.xdev.spring.data.eclipse.store.integration.shared.repositories.real.life.example.ArticleGroup; -import software.xdev.spring.data.eclipse.store.integration.shared.repositories.real.life.example.Invoice; -import software.xdev.spring.data.eclipse.store.integration.shared.repositories.real.life.example.InvoiceRepository; -import software.xdev.spring.data.eclipse.store.integration.shared.repositories.real.life.example.Position; -import software.xdev.spring.data.eclipse.store.integration.shared.repositories.real.life.example.PositionRepository; -import software.xdev.spring.data.eclipse.store.integration.shared.repositories.real.life.example.Warehouse; +import software.xdev.spring.data.eclipse.store.integration.isolated.IsolatedTestAnnotations; -@SuppressWarnings("OptionalGetWithoutIsPresent") -@DefaultTestAnnotations -class RealLifeTests +@IsolatedTestAnnotations +@ContextConfiguration(classes = {RealLifeExamplesTestConfiguration.class}) +class RealLifeExamplesTest { static final String STATIONERY = "Stationery"; static final String BUILDING_MATERIAL = "Building Material"; @@ -56,8 +49,13 @@ class RealLifeTests InvoiceRepository invoiceRepository; @Autowired PositionRepository positionRepository; + private final RealLifeExamplesTestConfiguration configuration; + @Autowired - private SharedTestConfiguration configuration; + public RealLifeExamplesTest(final RealLifeExamplesTestConfiguration configuration) + { + this.configuration = configuration; + } private Invoice buildDefaultModel() { diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/RealLifeExamplesTestConfiguration.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/RealLifeExamplesTestConfiguration.java new file mode 100644 index 00000000..4222895b --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/RealLifeExamplesTestConfiguration.java @@ -0,0 +1,53 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples; + +import org.eclipse.serializer.reflect.ClassLoaderProvider; +import org.eclipse.store.integrations.spring.boot.types.configuration.EclipseStoreProperties; +import org.eclipse.store.integrations.spring.boot.types.factories.EmbeddedStorageFoundationFactory; +import org.springframework.beans.factory.ObjectProvider; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.transaction.TransactionManagerCustomizers; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.transaction.PlatformTransactionManager; + +import software.xdev.spring.data.eclipse.store.integration.TestConfiguration; +import software.xdev.spring.data.eclipse.store.repository.config.EnableEclipseStoreRepositories; + + +@Configuration +@EnableEclipseStoreRepositories +public class RealLifeExamplesTestConfiguration extends TestConfiguration +{ + @Autowired + protected RealLifeExamplesTestConfiguration( + final EclipseStoreProperties defaultEclipseStoreProperties, + final EmbeddedStorageFoundationFactory defaultEclipseStoreProvider, + final ClassLoaderProvider classLoaderProvider) + { + super(defaultEclipseStoreProperties, defaultEclipseStoreProvider, classLoaderProvider); + } + + @Bean + @Override + public PlatformTransactionManager transactionManager( + final ObjectProvider transactionManagerCustomizers + ) + { + return super.transactionManager(transactionManagerCustomizers); + } +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/RealLifeTests.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/RealLifeTests.java new file mode 100644 index 00000000..d3c3a1ca --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/RealLifeTests.java @@ -0,0 +1,38 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples; + +import static software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.Position.getPositionWithArticleWithName; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; + +import software.xdev.spring.data.eclipse.store.helper.TestUtil; +import software.xdev.spring.data.eclipse.store.integration.shared.DefaultTestAnnotations; +import software.xdev.spring.data.eclipse.store.integration.shared.SharedTestConfiguration; + + +@SuppressWarnings("OptionalGetWithoutIsPresent") +@DefaultTestAnnotations +class RealLifeTests +{ + } diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/real/life/example/Warehouse.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/Warehouse.java similarity index 91% rename from spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/real/life/example/Warehouse.java rename to spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/Warehouse.java index 8d5b0663..598679a8 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/real/life/example/Warehouse.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/Warehouse.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package software.xdev.spring.data.eclipse.store.integration.shared.repositories.real.life.example; +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples; import java.util.HashSet; import java.util.Set; From e3a29c2f8597d7ecc7adc14e31ac1102870edcd4 Mon Sep 17 00:00:00 2001 From: JohannesRabauer Date: Mon, 9 Dec 2024 09:18:36 +0100 Subject: [PATCH 44/54] Delete RealLifeTests.java --- .../real/life/examples/RealLifeTests.java | 38 ------------------- 1 file changed, 38 deletions(-) delete mode 100644 spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/RealLifeTests.java diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/RealLifeTests.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/RealLifeTests.java deleted file mode 100644 index d3c3a1ca..00000000 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/RealLifeTests.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright © 2024 XDEV Software (https://xdev.software) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples; - -import static software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.Position.getPositionWithArticleWithName; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; - -import software.xdev.spring.data.eclipse.store.helper.TestUtil; -import software.xdev.spring.data.eclipse.store.integration.shared.DefaultTestAnnotations; -import software.xdev.spring.data.eclipse.store.integration.shared.SharedTestConfiguration; - - -@SuppressWarnings("OptionalGetWithoutIsPresent") -@DefaultTestAnnotations -class RealLifeTests -{ - } From 474f339e7d66b8f6531ccdeb1d9161093e98ee94 Mon Sep 17 00:00:00 2001 From: JohannesRabauer Date: Mon, 9 Dec 2024 09:46:46 +0100 Subject: [PATCH 45/54] Added Lazy Tests to real life example tests --- .../real/life/examples/InvoiceRepository.java | 2 + .../life/examples/PositionRepository.java | 2 + .../life/examples/RealLifeExamplesTest.java | 31 ++++++----- .../examples/lazy/InvoiceLazyRepository.java | 25 +++++++++ .../examples/lazy/PositionLazyRepository.java | 25 +++++++++ .../lazy/RealLifeExamplesLazyTest.java | 37 +++++++++++++ ...ealLifeExamplesLazyTestConfiguration.java} | 6 +-- .../life/examples/{ => model}/Article.java | 2 +- .../examples/{ => model}/ArticleGroup.java | 2 +- .../life/examples/{ => model}/Invoice.java | 2 +- .../life/examples/{ => model}/Position.java | 2 +- .../life/examples/{ => model}/Warehouse.java | 2 +- .../nonlazy/InvoiceNonLazyRepository.java | 26 +++++++++ .../nonlazy/PositionNonLazyRepository.java | 26 +++++++++ .../nonlazy/RealLifeExamplesNonLazyTest.java | 37 +++++++++++++ ...lLifeExamplesNonLazyTestConfiguration.java | 53 +++++++++++++++++++ 16 files changed, 258 insertions(+), 22 deletions(-) create mode 100644 spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/lazy/InvoiceLazyRepository.java create mode 100644 spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/lazy/PositionLazyRepository.java create mode 100644 spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/lazy/RealLifeExamplesLazyTest.java rename spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/{RealLifeExamplesTestConfiguration.java => lazy/RealLifeExamplesLazyTestConfiguration.java} (92%) rename spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/{ => model}/Article.java (97%) rename spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/{ => model}/ArticleGroup.java (95%) rename spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/{ => model}/Invoice.java (96%) rename spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/{ => model}/Position.java (97%) rename spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/{ => model}/Warehouse.java (96%) create mode 100644 spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/nonlazy/InvoiceNonLazyRepository.java create mode 100644 spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/nonlazy/PositionNonLazyRepository.java create mode 100644 spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/nonlazy/RealLifeExamplesNonLazyTest.java create mode 100644 spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/nonlazy/RealLifeExamplesNonLazyTestConfiguration.java diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/InvoiceRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/InvoiceRepository.java index 07186e01..2f5e4087 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/InvoiceRepository.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/InvoiceRepository.java @@ -17,6 +17,8 @@ import org.springframework.data.repository.CrudRepository; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.model.Invoice; + public interface InvoiceRepository extends CrudRepository { diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/PositionRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/PositionRepository.java index 4c545ba9..856ba8ad 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/PositionRepository.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/PositionRepository.java @@ -17,6 +17,8 @@ import org.springframework.data.repository.ListCrudRepository; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.model.Position; + public interface PositionRepository extends ListCrudRepository { diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/RealLifeExamplesTest.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/RealLifeExamplesTest.java index 9b263c2c..792c7010 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/RealLifeExamplesTest.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/RealLifeExamplesTest.java @@ -15,7 +15,7 @@ */ package software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples; -import static software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.Position.getPositionWithArticleWithName; +import static software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.model.Position.getPositionWithArticleWithName; import java.util.ArrayList; import java.util.Arrays; @@ -24,16 +24,17 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import software.xdev.spring.data.eclipse.store.helper.TestUtil; -import software.xdev.spring.data.eclipse.store.integration.isolated.IsolatedTestAnnotations; +import software.xdev.spring.data.eclipse.store.integration.TestConfiguration; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.model.Article; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.model.ArticleGroup; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.model.Invoice; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.model.Position; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.model.Warehouse; -@IsolatedTestAnnotations -@ContextConfiguration(classes = {RealLifeExamplesTestConfiguration.class}) -class RealLifeExamplesTest +public abstract class RealLifeExamplesTest { static final String STATIONERY = "Stationery"; static final String BUILDING_MATERIAL = "Building Material"; @@ -45,15 +46,17 @@ class RealLifeExamplesTest static final String SHOE_ARTICLE_NAME = "Shoe"; static final String SHOES_ARTICLE_GROUP = "Shoes"; - @Autowired - InvoiceRepository invoiceRepository; - @Autowired - PositionRepository positionRepository; - private final RealLifeExamplesTestConfiguration configuration; + final InvoiceRepository invoiceRepository; + final PositionRepository positionRepository; + private final TestConfiguration configuration; - @Autowired - public RealLifeExamplesTest(final RealLifeExamplesTestConfiguration configuration) + public RealLifeExamplesTest( + final InvoiceRepository invoiceRepository, + final PositionRepository positionRepository, + final TestConfiguration configuration) { + this.invoiceRepository = invoiceRepository; + this.positionRepository = positionRepository; this.configuration = configuration; } diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/lazy/InvoiceLazyRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/lazy/InvoiceLazyRepository.java new file mode 100644 index 00000000..56951332 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/lazy/InvoiceLazyRepository.java @@ -0,0 +1,25 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.lazy; + +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.InvoiceRepository; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.model.Invoice; +import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreCrudRepository; + + +public interface InvoiceLazyRepository extends LazyEclipseStoreCrudRepository, InvoiceRepository +{ +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/lazy/PositionLazyRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/lazy/PositionLazyRepository.java new file mode 100644 index 00000000..0aea547a --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/lazy/PositionLazyRepository.java @@ -0,0 +1,25 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.lazy; + +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.PositionRepository; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.model.Position; +import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreListCrudRepository; + + +public interface PositionLazyRepository extends LazyEclipseStoreListCrudRepository, PositionRepository +{ +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/lazy/RealLifeExamplesLazyTest.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/lazy/RealLifeExamplesLazyTest.java new file mode 100644 index 00000000..331fa50f --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/lazy/RealLifeExamplesLazyTest.java @@ -0,0 +1,37 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.lazy; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; + +import software.xdev.spring.data.eclipse.store.integration.isolated.IsolatedTestAnnotations; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.RealLifeExamplesTest; + + +@IsolatedTestAnnotations +@ContextConfiguration(classes = {RealLifeExamplesLazyTestConfiguration.class}) +class RealLifeExamplesLazyTest extends RealLifeExamplesTest +{ + @Autowired + public RealLifeExamplesLazyTest( + final InvoiceLazyRepository invoiceRepository, + final PositionLazyRepository positionRepository, + final RealLifeExamplesLazyTestConfiguration configuration) + { + super(invoiceRepository, positionRepository, configuration); + } +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/RealLifeExamplesTestConfiguration.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/lazy/RealLifeExamplesLazyTestConfiguration.java similarity index 92% rename from spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/RealLifeExamplesTestConfiguration.java rename to spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/lazy/RealLifeExamplesLazyTestConfiguration.java index 4222895b..c1b8ffa2 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/RealLifeExamplesTestConfiguration.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/lazy/RealLifeExamplesLazyTestConfiguration.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples; +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.lazy; import org.eclipse.serializer.reflect.ClassLoaderProvider; import org.eclipse.store.integrations.spring.boot.types.configuration.EclipseStoreProperties; @@ -31,10 +31,10 @@ @Configuration @EnableEclipseStoreRepositories -public class RealLifeExamplesTestConfiguration extends TestConfiguration +public class RealLifeExamplesLazyTestConfiguration extends TestConfiguration { @Autowired - protected RealLifeExamplesTestConfiguration( + protected RealLifeExamplesLazyTestConfiguration( final EclipseStoreProperties defaultEclipseStoreProperties, final EmbeddedStorageFoundationFactory defaultEclipseStoreProvider, final ClassLoaderProvider classLoaderProvider) diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/Article.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/model/Article.java similarity index 97% rename from spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/Article.java rename to spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/model/Article.java index 2f1e12f5..d4131d6e 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/Article.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/model/Article.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples; +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.model; import java.util.ArrayList; import java.util.Collections; diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/ArticleGroup.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/model/ArticleGroup.java similarity index 95% rename from spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/ArticleGroup.java rename to spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/model/ArticleGroup.java index f21a1eb3..9cae714f 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/ArticleGroup.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/model/ArticleGroup.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples; +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.model; public class ArticleGroup { diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/Invoice.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/model/Invoice.java similarity index 96% rename from spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/Invoice.java rename to spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/model/Invoice.java index 5fed9d10..f930fd25 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/Invoice.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/model/Invoice.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples; +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.model; import java.util.List; diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/Position.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/model/Position.java similarity index 97% rename from spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/Position.java rename to spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/model/Position.java index 78702d16..137328a5 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/Position.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/model/Position.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples; +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.model; import java.util.List; import java.util.Optional; diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/Warehouse.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/model/Warehouse.java similarity index 96% rename from spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/Warehouse.java rename to spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/model/Warehouse.java index 598679a8..bde4b9c3 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/Warehouse.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/model/Warehouse.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples; +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.model; import java.util.HashSet; import java.util.Set; diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/nonlazy/InvoiceNonLazyRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/nonlazy/InvoiceNonLazyRepository.java new file mode 100644 index 00000000..e90ef4cd --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/nonlazy/InvoiceNonLazyRepository.java @@ -0,0 +1,26 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.nonlazy; + +import org.springframework.data.repository.CrudRepository; + +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.InvoiceRepository; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.model.Invoice; + + +public interface InvoiceNonLazyRepository extends CrudRepository, InvoiceRepository +{ +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/nonlazy/PositionNonLazyRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/nonlazy/PositionNonLazyRepository.java new file mode 100644 index 00000000..e4212f99 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/nonlazy/PositionNonLazyRepository.java @@ -0,0 +1,26 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.nonlazy; + +import org.springframework.data.repository.ListCrudRepository; + +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.PositionRepository; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.model.Position; + + +public interface PositionNonLazyRepository extends ListCrudRepository, PositionRepository +{ +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/nonlazy/RealLifeExamplesNonLazyTest.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/nonlazy/RealLifeExamplesNonLazyTest.java new file mode 100644 index 00000000..069c2803 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/nonlazy/RealLifeExamplesNonLazyTest.java @@ -0,0 +1,37 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.nonlazy; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; + +import software.xdev.spring.data.eclipse.store.integration.isolated.IsolatedTestAnnotations; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.RealLifeExamplesTest; + + +@IsolatedTestAnnotations +@ContextConfiguration(classes = {RealLifeExamplesNonLazyTestConfiguration.class}) +class RealLifeExamplesNonLazyTest extends RealLifeExamplesTest +{ + @Autowired + public RealLifeExamplesNonLazyTest( + final InvoiceNonLazyRepository invoiceRepository, + final PositionNonLazyRepository positionRepository, + final RealLifeExamplesNonLazyTestConfiguration configuration) + { + super(invoiceRepository, positionRepository, configuration); + } +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/nonlazy/RealLifeExamplesNonLazyTestConfiguration.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/nonlazy/RealLifeExamplesNonLazyTestConfiguration.java new file mode 100644 index 00000000..747328e2 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/nonlazy/RealLifeExamplesNonLazyTestConfiguration.java @@ -0,0 +1,53 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.nonlazy; + +import org.eclipse.serializer.reflect.ClassLoaderProvider; +import org.eclipse.store.integrations.spring.boot.types.configuration.EclipseStoreProperties; +import org.eclipse.store.integrations.spring.boot.types.factories.EmbeddedStorageFoundationFactory; +import org.springframework.beans.factory.ObjectProvider; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.transaction.TransactionManagerCustomizers; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.transaction.PlatformTransactionManager; + +import software.xdev.spring.data.eclipse.store.integration.TestConfiguration; +import software.xdev.spring.data.eclipse.store.repository.config.EnableEclipseStoreRepositories; + + +@Configuration +@EnableEclipseStoreRepositories +public class RealLifeExamplesNonLazyTestConfiguration extends TestConfiguration +{ + @Autowired + protected RealLifeExamplesNonLazyTestConfiguration( + final EclipseStoreProperties defaultEclipseStoreProperties, + final EmbeddedStorageFoundationFactory defaultEclipseStoreProvider, + final ClassLoaderProvider classLoaderProvider) + { + super(defaultEclipseStoreProperties, defaultEclipseStoreProvider, classLoaderProvider); + } + + @Bean + @Override + public PlatformTransactionManager transactionManager( + final ObjectProvider transactionManagerCustomizers + ) + { + return super.transactionManager(transactionManagerCustomizers); + } +} From 1846bc5abc0d9c660ba47538aaf7d7d891bf41dd Mon Sep 17 00:00:00 2001 From: JohannesRabauer Date: Mon, 9 Dec 2024 13:22:39 +0100 Subject: [PATCH 46/54] Fixed some lazy repo problems --- .../store/repository/EclipseStoreStorage.java | 4 +-- .../repository/root/v2_4/LazyEntityData.java | 27 ++++++++++++------- .../store/helper/DummyEntityProvider.java | 2 +- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreStorage.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreStorage.java index d74cc08e..44e171c9 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreStorage.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreStorage.java @@ -212,11 +212,11 @@ public void createNewEntityData(final Class entityClass, final Versio final SimpleEclipseStoreRepository repository = this.entityClassToRepository.get(entityClass); if(repository != null && repository.isLazy()) { - root.getCurrentRootData().createNewLazyEntityData(entityClass, idManager); + root.getCurrentRootData().createNewLazyEntityData(entityClass, idManager.hasIdField() ? idManager : null); } else { - root.getCurrentRootData().createNewEntityData(entityClass, idManager); + root.getCurrentRootData().createNewEntityData(entityClass, idManager.hasIdField() ? idManager : null); } } diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/LazyEntityData.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/LazyEntityData.java index 87a348af..d4b805cf 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/LazyEntityData.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/LazyEntityData.java @@ -18,7 +18,6 @@ import java.util.Collection; import java.util.HashMap; import java.util.List; -import java.util.function.Function; import java.util.stream.Stream; import org.eclipse.serializer.reference.Lazy; @@ -83,7 +82,8 @@ public boolean containsEntity(final T entity) else { final ID id = this.idGetter.getId(entity); - return this.entitiesById.containsKey(id); + final Lazy existingEntity = this.entitiesById.get(id); + return existingEntity != null && existingEntity.get() == entity; } } @@ -128,18 +128,25 @@ public void setLastId(final Object lastId) @Override public Collection ensureEntityAndReturnObjectsToStore(final T entityToStore) { - if(!this.containsEntity(entityToStore)) + Collection listToSave = List.of(); + if(this.idGetter == null && !this.containsEntity(entityToStore)) { - final SpringDataEclipseStoreLazy.Default newLazyEntity = - SpringDataEclipseStoreLazy.build(entityToStore); - this.entities.add(newLazyEntity); - if(this.idGetter != null) + this.entities.add(SpringDataEclipseStoreLazy.build(entityToStore)); + listToSave = this.getObjectsToStore(); + } + if(this.idGetter != null) + { + final Lazy existingEntity = this.entitiesById.get(this.idGetter.getId(entityToStore)); + if(existingEntity == null || existingEntity.get() != entityToStore) { - this.entitiesById.put(this.idGetter.getId(entityToStore), newLazyEntity); + this.entities.remove(existingEntity); + final SpringDataEclipseStoreLazy newLazyInstance = SpringDataEclipseStoreLazy.build(entityToStore); + this.entities.add(newLazyInstance); + this.entitiesById.put(this.idGetter.getId(entityToStore), newLazyInstance); + listToSave = this.getObjectsToStore(); } - return this.getObjectsToStore(); } - return List.of(); + return listToSave; } @Override diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/helper/DummyEntityProvider.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/helper/DummyEntityProvider.java index 3dab0346..a7767bd6 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/helper/DummyEntityProvider.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/helper/DummyEntityProvider.java @@ -29,7 +29,7 @@ public DummyEntityProvider(final Collection collection) { super(); final EntityData objects = new NonLazyEntityData<>(); - objects.setIdGetter(i -> null); + objects.setIdGetter(null); collection.forEach(objects::ensureEntityAndReturnObjectsToStore); this.addEntityData(objects); } From dea9f9e5dcd6b6a244a0a89244a4e1de93d88fbc Mon Sep 17 00:00:00 2001 From: JohannesRabauer Date: Mon, 9 Dec 2024 13:43:31 +0100 Subject: [PATCH 47/54] Moved Simple Tests to isolated tests --- .../tests/simple}/SimpleMultipleTest.java | 38 +++++++++------- .../tests/simple}/SimpleSingleTest.java | 38 +++++++++------- .../tests/simple/SimpleTestConfiguration.java | 40 +++++++++++++++++ .../tests/simple/model/Customer.java} | 25 +++-------- .../tests/simple/model}/CustomerAsRecord.java | 2 +- .../model}/CustomerAsRecordRepository.java | 2 +- .../tests/simple/model}/CustomerNotCrud.java | 2 +- .../model}/CustomerNotCrudRepository.java | 2 +- .../simple/model/CustomerRepository.java | 45 +++++++++++++++++++ .../tests/simple/model}/Owner.java | 2 +- .../tests/simple/model}/OwnerRepository.java | 2 +- .../tests/simple/model/ParentCustomer.java} | 17 ++++--- .../CustomerWithChildRepository.java | 26 ----------- 13 files changed, 154 insertions(+), 87 deletions(-) rename spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/{shared/tests => isolated/tests/simple}/SimpleMultipleTest.java (80%) rename spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/{shared/tests => isolated/tests/simple}/SimpleSingleTest.java (85%) create mode 100644 spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/SimpleTestConfiguration.java rename spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/{shared/repositories/CustomerWithChild.java => isolated/tests/simple/model/Customer.java} (76%) rename spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/{shared/repositories => isolated/tests/simple/model}/CustomerAsRecord.java (91%) rename spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/{shared/repositories => isolated/tests/simple/model}/CustomerAsRecordRepository.java (90%) rename spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/{shared/repositories => isolated/tests/simple/model}/CustomerNotCrud.java (94%) rename spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/{shared/repositories => isolated/tests/simple/model}/CustomerNotCrudRepository.java (90%) create mode 100644 spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/model/CustomerRepository.java rename spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/{shared/repositories => isolated/tests/simple/model}/Owner.java (95%) rename spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/{shared/repositories => isolated/tests/simple/model}/OwnerRepository.java (89%) rename spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/{shared/repositories/Child.java => isolated/tests/simple/model/ParentCustomer.java} (72%) delete mode 100644 spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/CustomerWithChildRepository.java diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/tests/SimpleMultipleTest.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/SimpleMultipleTest.java similarity index 80% rename from spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/tests/SimpleMultipleTest.java rename to spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/SimpleMultipleTest.java index a9650158..5b936b80 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/tests/SimpleMultipleTest.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/SimpleMultipleTest.java @@ -13,33 +13,42 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package software.xdev.spring.data.eclipse.store.integration.shared.tests; +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple; import java.util.List; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; import software.xdev.spring.data.eclipse.store.helper.TestData; import software.xdev.spring.data.eclipse.store.helper.TestUtil; -import software.xdev.spring.data.eclipse.store.integration.shared.DefaultTestAnnotations; -import software.xdev.spring.data.eclipse.store.integration.shared.SharedTestConfiguration; -import software.xdev.spring.data.eclipse.store.integration.shared.repositories.Customer; -import software.xdev.spring.data.eclipse.store.integration.shared.repositories.CustomerRepository; -import software.xdev.spring.data.eclipse.store.integration.shared.repositories.Owner; -import software.xdev.spring.data.eclipse.store.integration.shared.repositories.OwnerRepository; +import software.xdev.spring.data.eclipse.store.integration.isolated.IsolatedTestAnnotations; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.Customer; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.CustomerRepository; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.Owner; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.OwnerRepository; -@DefaultTestAnnotations +@IsolatedTestAnnotations +@ContextConfiguration(classes = {SimpleTestConfiguration.class}) class SimpleMultipleTest { + private final CustomerRepository customerRepository; + private final OwnerRepository ownerRepository; + private final SimpleTestConfiguration configuration; + @Autowired - private CustomerRepository customerRepository; - @Autowired - private OwnerRepository ownerRepository; - @Autowired - private SharedTestConfiguration configuration; + public SimpleMultipleTest( + final CustomerRepository customerRepository, + final OwnerRepository ownerRepository, + final SimpleTestConfiguration configuration) + { + this.customerRepository = customerRepository; + this.ownerRepository = ownerRepository; + this.configuration = configuration; + } @Test void testBasicSaveAndFindAll() @@ -48,8 +57,7 @@ void testBasicSaveAndFindAll() customer = new Customer(TestData.FIRST_NAME, TestData.LAST_NAME); this.customerRepository.save(customer); - final Owner - owner = new Owner(TestData.FIRST_NAME, TestData.LAST_NAME); + final Owner owner = new Owner(TestData.FIRST_NAME, TestData.LAST_NAME); this.ownerRepository.save(owner); TestUtil.doBeforeAndAfterRestartOfDatastore( diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/tests/SimpleSingleTest.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/SimpleSingleTest.java similarity index 85% rename from spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/tests/SimpleSingleTest.java rename to spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/SimpleSingleTest.java index 7aa33866..a2799112 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/tests/SimpleSingleTest.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/SimpleSingleTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package software.xdev.spring.data.eclipse.store.integration.shared.tests; +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple; import java.util.ArrayList; import java.util.List; @@ -22,29 +22,37 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; import software.xdev.spring.data.eclipse.store.helper.TestData; import software.xdev.spring.data.eclipse.store.helper.TestUtil; -import software.xdev.spring.data.eclipse.store.integration.shared.DefaultTestAnnotations; -import software.xdev.spring.data.eclipse.store.integration.shared.SharedTestConfiguration; -import software.xdev.spring.data.eclipse.store.integration.shared.repositories.Customer; -import software.xdev.spring.data.eclipse.store.integration.shared.repositories.CustomerAsRecord; -import software.xdev.spring.data.eclipse.store.integration.shared.repositories.CustomerAsRecordRepository; -import software.xdev.spring.data.eclipse.store.integration.shared.repositories.CustomerNotCrud; -import software.xdev.spring.data.eclipse.store.integration.shared.repositories.CustomerNotCrudRepository; -import software.xdev.spring.data.eclipse.store.integration.shared.repositories.CustomerRepository; +import software.xdev.spring.data.eclipse.store.integration.isolated.IsolatedTestAnnotations; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.Customer; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.CustomerAsRecord; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.CustomerAsRecordRepository; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.CustomerNotCrud; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.CustomerNotCrudRepository; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.CustomerRepository; -@DefaultTestAnnotations +@IsolatedTestAnnotations +@ContextConfiguration(classes = {SimpleTestConfiguration.class}) class SimpleSingleTest { - @Autowired - private CustomerRepository repository; - @Autowired - private CustomerAsRecordRepository recordRepository; + private final CustomerRepository repository; + private final CustomerAsRecordRepository recordRepository; + private final SimpleTestConfiguration configuration; @Autowired - private SharedTestConfiguration configuration; + public SimpleSingleTest( + final CustomerRepository repository, + final CustomerAsRecordRepository recordRepository, + final SimpleTestConfiguration configuration) + { + this.repository = repository; + this.recordRepository = recordRepository; + this.configuration = configuration; + } @Test void testNullFindAll() diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/SimpleTestConfiguration.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/SimpleTestConfiguration.java new file mode 100644 index 00000000..b7748c38 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/SimpleTestConfiguration.java @@ -0,0 +1,40 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple; + +import org.eclipse.serializer.reflect.ClassLoaderProvider; +import org.eclipse.store.integrations.spring.boot.types.configuration.EclipseStoreProperties; +import org.eclipse.store.integrations.spring.boot.types.factories.EmbeddedStorageFoundationFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; + +import software.xdev.spring.data.eclipse.store.integration.TestConfiguration; +import software.xdev.spring.data.eclipse.store.repository.config.EnableEclipseStoreRepositories; + + +@Configuration +@EnableEclipseStoreRepositories +public class SimpleTestConfiguration extends TestConfiguration +{ + @Autowired + protected SimpleTestConfiguration( + final EclipseStoreProperties defaultEclipseStoreProperties, + final EmbeddedStorageFoundationFactory defaultEclipseStoreProvider, + final ClassLoaderProvider classLoaderProvider) + { + super(defaultEclipseStoreProperties, defaultEclipseStoreProvider, classLoaderProvider); + } +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/CustomerWithChild.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/model/Customer.java similarity index 76% rename from spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/CustomerWithChild.java rename to spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/model/Customer.java index 07f1ca9d..097d4766 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/CustomerWithChild.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/model/Customer.java @@ -13,24 +13,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package software.xdev.spring.data.eclipse.store.integration.shared.repositories; +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model; import java.util.List; import java.util.Objects; -public class CustomerWithChild +public class Customer { private String firstName; private String lastName; - private Child child; - - public CustomerWithChild(final String firstName, final String lastName, final Child child) + public Customer(final String firstName, final String lastName) { this.firstName = firstName; this.lastName = lastName; - this.child = child; } public String getFirstName() @@ -53,16 +50,6 @@ public void setLastName(final String lastName) this.lastName = lastName; } - public Child getChild() - { - return this.child; - } - - public void setChild(final Child child) - { - this.child = child; - } - @Override public String toString() { @@ -82,7 +69,7 @@ public boolean equals(final Object o) { return false; } - final CustomerWithChild customer = (CustomerWithChild)o; + final Customer customer = (Customer)o; return Objects.equals(this.firstName, customer.firstName) && Objects.equals( this.lastName, customer.lastName); @@ -95,9 +82,7 @@ public int hashCode() } @SuppressWarnings("OptionalGetWithoutIsPresent") - public static CustomerWithChild getCustomerWithFirstName( - final List customers, - final String firstName) + public static Customer getCustomerWithFirstName(final List customers, final String firstName) { return customers.stream().filter(customer -> customer.getFirstName().equals(firstName)).findFirst().get(); } diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/CustomerAsRecord.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/model/CustomerAsRecord.java similarity index 91% rename from spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/CustomerAsRecord.java rename to spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/model/CustomerAsRecord.java index ab242afa..02aef14c 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/CustomerAsRecord.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/model/CustomerAsRecord.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package software.xdev.spring.data.eclipse.store.integration.shared.repositories; +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model; import java.util.List; diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/CustomerAsRecordRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/model/CustomerAsRecordRepository.java similarity index 90% rename from spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/CustomerAsRecordRepository.java rename to spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/model/CustomerAsRecordRepository.java index 8119fc23..fbdbcacd 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/CustomerAsRecordRepository.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/model/CustomerAsRecordRepository.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package software.xdev.spring.data.eclipse.store.integration.shared.repositories; +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model; import java.util.Optional; diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/CustomerNotCrud.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/model/CustomerNotCrud.java similarity index 94% rename from spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/CustomerNotCrud.java rename to spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/model/CustomerNotCrud.java index 00835cdc..c31e9f13 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/CustomerNotCrud.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/model/CustomerNotCrud.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package software.xdev.spring.data.eclipse.store.integration.shared.repositories; +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model; import java.util.Objects; diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/CustomerNotCrudRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/model/CustomerNotCrudRepository.java similarity index 90% rename from spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/CustomerNotCrudRepository.java rename to spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/model/CustomerNotCrudRepository.java index 29e21eb9..e1701078 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/CustomerNotCrudRepository.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/model/CustomerNotCrudRepository.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package software.xdev.spring.data.eclipse.store.integration.shared.repositories; +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model; import java.util.List; diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/model/CustomerRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/model/CustomerRepository.java new file mode 100644 index 00000000..07d191b8 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/model/CustomerRepository.java @@ -0,0 +1,45 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model; + +import java.util.List; +import java.util.Optional; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; + + +public interface CustomerRepository + extends CrudRepository, PagingAndSortingRepository +{ + Optional findByFirstName(String firstName); + + Iterable findAllByLastName(String lastName); + + @Override + Page findAll(Pageable pageable); + + Page findAllByLastName(String lastName, Pageable pageable); + + List findByOrderByLastNameAsc(); + + Iterable findAllByLastName(String lastName, Sort sort); + + List findAllByFirstName(String lastName, Pageable pageable); +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/Owner.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/model/Owner.java similarity index 95% rename from spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/Owner.java rename to spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/model/Owner.java index 43ac8d71..cd5c263b 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/Owner.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/model/Owner.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package software.xdev.spring.data.eclipse.store.integration.shared.repositories; +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model; import java.util.List; import java.util.Objects; diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/OwnerRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/model/OwnerRepository.java similarity index 89% rename from spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/OwnerRepository.java rename to spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/model/OwnerRepository.java index 72a47207..32e0af06 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/OwnerRepository.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/model/OwnerRepository.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package software.xdev.spring.data.eclipse.store.integration.shared.repositories; +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model; import org.springframework.data.repository.CrudRepository; diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/Child.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/model/ParentCustomer.java similarity index 72% rename from spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/Child.java rename to spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/model/ParentCustomer.java index 64521977..7970108c 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/Child.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/model/ParentCustomer.java @@ -13,17 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package software.xdev.spring.data.eclipse.store.integration.shared.repositories; +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model; +import java.util.List; import java.util.Objects; -public class Child +public class ParentCustomer { private String firstName; private String lastName; - public Child(final String firstName, final String lastName) + public ParentCustomer(final String firstName, final String lastName) { this.firstName = firstName; this.lastName = lastName; @@ -53,7 +54,7 @@ public void setLastName(final String lastName) public String toString() { return String.format( - "Child[firstName='%s', lastName='%s']", + "Customer[firstName='%s', lastName='%s']", this.firstName, this.lastName); } @@ -68,7 +69,7 @@ public boolean equals(final Object o) { return false; } - final Child customer = (Child)o; + final ParentCustomer customer = (ParentCustomer)o; return Objects.equals(this.firstName, customer.firstName) && Objects.equals( this.lastName, customer.lastName); @@ -79,4 +80,10 @@ public int hashCode() { return Objects.hash(this.firstName, this.lastName); } + + @SuppressWarnings("OptionalGetWithoutIsPresent") + public static ParentCustomer getCustomerWithFirstName(final List customers, final String firstName) + { + return customers.stream().filter(customer -> customer.getFirstName().equals(firstName)).findFirst().get(); + } } diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/CustomerWithChildRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/CustomerWithChildRepository.java deleted file mode 100644 index 25e6e98d..00000000 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/CustomerWithChildRepository.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright © 2024 XDEV Software (https://xdev.software) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package software.xdev.spring.data.eclipse.store.integration.shared.repositories; - -import java.util.Optional; - -import org.springframework.data.repository.CrudRepository; - - -public interface CustomerWithChildRepository extends CrudRepository -{ - Optional findByChild(Child child); -} From c597730e6fec6ca23bcbce40ba768bd4d3501649 Mon Sep 17 00:00:00 2001 From: JohannesRabauer Date: Mon, 9 Dec 2024 14:04:33 +0100 Subject: [PATCH 48/54] Simple Tests now work with LazyRepositories --- ...StoreRepositoryConfigurationExtension.java | 8 ++-- ...eStoreListPagingAndSortingRepository.java} | 2 +- ...lipseStorePagingAndSortingRepository.java} | 2 +- .../interfaces/EclipseStoreRepository.java | 2 +- .../support/SimpleEclipseStoreRepository.java | 8 ++-- .../life/examples/RealLifeExamplesTest.java | 2 + .../examples/lazy/InvoiceLazyRepository.java | 2 +- .../examples/lazy/PositionLazyRepository.java | 2 +- .../{ => model}/InvoiceRepository.java | 4 +- .../{ => model}/PositionRepository.java | 4 +- .../nonlazy/InvoiceNonLazyRepository.java | 2 +- .../nonlazy/PositionNonLazyRepository.java | 2 +- .../tests/simple/SimpleMultipleTest.java | 11 +++-- .../tests/simple/SimpleSingleTest.java | 17 ++++---- .../lazy/CustomerAsRecordLazyRepository.java | 28 +++++++++++++ .../simple/lazy/CustomerLazyRepository.java | 34 ++++++++++++++++ .../lazy/CustomerNotCrudLazyRepository.java | 27 +++++++++++++ .../simple/lazy/LazySimpleMultipleTest.java | 22 ++++++++++ .../simple/lazy/LazySimpleSingleTest.java | 23 +++++++++++ .../simple/lazy/OwnerLazyRepository.java | 25 ++++++++++++ .../SimpleLazyTestConfiguration.java} | 6 +-- .../model/CustomerNotCrudRepository.java | 2 +- .../simple/model/CustomerRepository.java | 10 ----- .../CustomerAsRecordNonLazyRepository.java | 27 +++++++++++++ .../nonlazy/CustomerNonLazyRepository.java | 31 ++++++++++++++ .../CustomerNotCrudNonLazyRepository.java | 28 +++++++++++++ .../nonlazy/NonLazySimpleMultipleTest.java | 22 ++++++++++ .../nonlazy/NonLazySimpleSingleTest.java | 23 +++++++++++ .../nonlazy/OwnerNonLazyRepository.java | 25 ++++++++++++ .../SimpleNonLazyTestConfiguration.java | 40 +++++++++++++++++++ ...seStoreListPagingAndSortingRepository.java | 4 +- ...clipseStorePagingAndSortingRepository.java | 4 +- 32 files changed, 395 insertions(+), 54 deletions(-) rename spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/{EclipseStoreListPagingAndSortingRepositoryRepository.java => EclipseStoreListPagingAndSortingRepository.java} (92%) rename spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/{EclipseStorePagingAndSortingRepositoryRepository.java => EclipseStorePagingAndSortingRepository.java} (92%) rename spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/{ => model}/InvoiceRepository.java (85%) rename spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/{ => model}/PositionRepository.java (85%) create mode 100644 spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/CustomerAsRecordLazyRepository.java create mode 100644 spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/CustomerLazyRepository.java create mode 100644 spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/CustomerNotCrudLazyRepository.java create mode 100644 spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/LazySimpleMultipleTest.java create mode 100644 spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/LazySimpleSingleTest.java create mode 100644 spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/OwnerLazyRepository.java rename spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/{SimpleTestConfiguration.java => lazy/SimpleLazyTestConfiguration.java} (92%) create mode 100644 spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/CustomerAsRecordNonLazyRepository.java create mode 100644 spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/CustomerNonLazyRepository.java create mode 100644 spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/CustomerNotCrudNonLazyRepository.java create mode 100644 spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/NonLazySimpleMultipleTest.java create mode 100644 spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/NonLazySimpleSingleTest.java create mode 100644 spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/OwnerNonLazyRepository.java create mode 100644 spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/SimpleNonLazyTestConfiguration.java diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/config/EclipseStoreRepositoryConfigurationExtension.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/config/EclipseStoreRepositoryConfigurationExtension.java index 5a39a185..4a98e2cf 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/config/EclipseStoreRepositoryConfigurationExtension.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/config/EclipseStoreRepositoryConfigurationExtension.java @@ -34,8 +34,8 @@ import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreCrudRepository; import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreCustomRepository; import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreListCrudRepository; -import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreListPagingAndSortingRepositoryRepository; -import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStorePagingAndSortingRepositoryRepository; +import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreListPagingAndSortingRepository; +import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStorePagingAndSortingRepository; import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository; import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreCrudRepository; import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreCustomRepository; @@ -125,8 +125,8 @@ protected Collection> getIdentifyingTypes() return List.of( EclipseStoreRepository.class, EclipseStoreCustomRepository.class, - EclipseStorePagingAndSortingRepositoryRepository.class, - EclipseStoreListPagingAndSortingRepositoryRepository.class, + EclipseStorePagingAndSortingRepository.class, + EclipseStoreListPagingAndSortingRepository.class, EclipseStoreCrudRepository.class, EclipseStoreListCrudRepository.class, LazyEclipseStoreRepository.class, diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/EclipseStoreListPagingAndSortingRepositoryRepository.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/EclipseStoreListPagingAndSortingRepository.java similarity index 92% rename from spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/EclipseStoreListPagingAndSortingRepositoryRepository.java rename to spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/EclipseStoreListPagingAndSortingRepository.java index 72be795d..8909e6a1 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/EclipseStoreListPagingAndSortingRepositoryRepository.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/EclipseStoreListPagingAndSortingRepository.java @@ -21,7 +21,7 @@ @SuppressWarnings("java:S119") @NoRepositoryBean -public interface EclipseStoreListPagingAndSortingRepositoryRepository +public interface EclipseStoreListPagingAndSortingRepository extends ListPagingAndSortingRepository { } diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/EclipseStorePagingAndSortingRepositoryRepository.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/EclipseStorePagingAndSortingRepository.java similarity index 92% rename from spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/EclipseStorePagingAndSortingRepositoryRepository.java rename to spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/EclipseStorePagingAndSortingRepository.java index a4c4b37c..9d72eb1d 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/EclipseStorePagingAndSortingRepositoryRepository.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/EclipseStorePagingAndSortingRepository.java @@ -21,7 +21,7 @@ @SuppressWarnings("java:S119") @NoRepositoryBean -public interface EclipseStorePagingAndSortingRepositoryRepository +public interface EclipseStorePagingAndSortingRepository extends PagingAndSortingRepository { } diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/EclipseStoreRepository.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/EclipseStoreRepository.java index 3fb889dd..75a41c4c 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/EclipseStoreRepository.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/EclipseStoreRepository.java @@ -23,7 +23,7 @@ public interface EclipseStoreRepository extends EclipseStoreListCrudRepository, - EclipseStoreListPagingAndSortingRepositoryRepository, + EclipseStoreListPagingAndSortingRepository, EclipseStoreQueryByExampleExecutor { } diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/SimpleEclipseStoreRepository.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/SimpleEclipseStoreRepository.java index d744a436..820fde36 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/SimpleEclipseStoreRepository.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/SimpleEclipseStoreRepository.java @@ -38,8 +38,8 @@ import software.xdev.spring.data.eclipse.store.repository.access.AccessHelper; import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreCrudRepository; import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreListCrudRepository; -import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreListPagingAndSortingRepositoryRepository; -import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStorePagingAndSortingRepositoryRepository; +import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreListPagingAndSortingRepository; +import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStorePagingAndSortingRepository; import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreQueryByExampleExecutor; import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository; import software.xdev.spring.data.eclipse.store.repository.query.by.example.EclipseStoreFetchableFluentQuery; @@ -61,8 +61,8 @@ public class SimpleEclipseStoreRepository implements EclipseStoreRepository, - EclipseStorePagingAndSortingRepositoryRepository, - EclipseStoreListPagingAndSortingRepositoryRepository, + EclipseStorePagingAndSortingRepository, + EclipseStoreListPagingAndSortingRepository, EclipseStoreCrudRepository, EclipseStoreListCrudRepository, EclipseStoreQueryByExampleExecutor diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/RealLifeExamplesTest.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/RealLifeExamplesTest.java index 792c7010..49705a39 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/RealLifeExamplesTest.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/RealLifeExamplesTest.java @@ -30,7 +30,9 @@ import software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.model.Article; import software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.model.ArticleGroup; import software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.model.Invoice; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.model.InvoiceRepository; import software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.model.Position; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.model.PositionRepository; import software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.model.Warehouse; diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/lazy/InvoiceLazyRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/lazy/InvoiceLazyRepository.java index 56951332..5cb3ffb6 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/lazy/InvoiceLazyRepository.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/lazy/InvoiceLazyRepository.java @@ -15,8 +15,8 @@ */ package software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.lazy; -import software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.InvoiceRepository; import software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.model.Invoice; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.model.InvoiceRepository; import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreCrudRepository; diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/lazy/PositionLazyRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/lazy/PositionLazyRepository.java index 0aea547a..4ade1081 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/lazy/PositionLazyRepository.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/lazy/PositionLazyRepository.java @@ -15,8 +15,8 @@ */ package software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.lazy; -import software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.PositionRepository; import software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.model.Position; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.model.PositionRepository; import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreListCrudRepository; diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/InvoiceRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/model/InvoiceRepository.java similarity index 85% rename from spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/InvoiceRepository.java rename to spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/model/InvoiceRepository.java index 2f5e4087..c1046fbd 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/InvoiceRepository.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/model/InvoiceRepository.java @@ -13,12 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples; +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.model; import org.springframework.data.repository.CrudRepository; -import software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.model.Invoice; - public interface InvoiceRepository extends CrudRepository { diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/PositionRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/model/PositionRepository.java similarity index 85% rename from spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/PositionRepository.java rename to spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/model/PositionRepository.java index 856ba8ad..f79de823 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/PositionRepository.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/model/PositionRepository.java @@ -13,12 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples; +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.model; import org.springframework.data.repository.ListCrudRepository; -import software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.model.Position; - public interface PositionRepository extends ListCrudRepository { diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/nonlazy/InvoiceNonLazyRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/nonlazy/InvoiceNonLazyRepository.java index e90ef4cd..983bc4b0 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/nonlazy/InvoiceNonLazyRepository.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/nonlazy/InvoiceNonLazyRepository.java @@ -17,8 +17,8 @@ import org.springframework.data.repository.CrudRepository; -import software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.InvoiceRepository; import software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.model.Invoice; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.model.InvoiceRepository; public interface InvoiceNonLazyRepository extends CrudRepository, InvoiceRepository diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/nonlazy/PositionNonLazyRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/nonlazy/PositionNonLazyRepository.java index e4212f99..e265effd 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/nonlazy/PositionNonLazyRepository.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/real/life/examples/nonlazy/PositionNonLazyRepository.java @@ -17,8 +17,8 @@ import org.springframework.data.repository.ListCrudRepository; -import software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.PositionRepository; import software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.model.Position; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.real.life.examples.model.PositionRepository; public interface PositionNonLazyRepository extends ListCrudRepository, PositionRepository diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/SimpleMultipleTest.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/SimpleMultipleTest.java index 5b936b80..f9b68acc 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/SimpleMultipleTest.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/SimpleMultipleTest.java @@ -24,26 +24,25 @@ import software.xdev.spring.data.eclipse.store.helper.TestData; import software.xdev.spring.data.eclipse.store.helper.TestUtil; +import software.xdev.spring.data.eclipse.store.integration.TestConfiguration; import software.xdev.spring.data.eclipse.store.integration.isolated.IsolatedTestAnnotations; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.lazy.SimpleLazyTestConfiguration; import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.Customer; import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.CustomerRepository; import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.Owner; import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.OwnerRepository; -@IsolatedTestAnnotations -@ContextConfiguration(classes = {SimpleTestConfiguration.class}) -class SimpleMultipleTest +public abstract class SimpleMultipleTest { private final CustomerRepository customerRepository; private final OwnerRepository ownerRepository; - private final SimpleTestConfiguration configuration; + private final TestConfiguration configuration; - @Autowired public SimpleMultipleTest( final CustomerRepository customerRepository, final OwnerRepository ownerRepository, - final SimpleTestConfiguration configuration) + final TestConfiguration configuration) { this.customerRepository = customerRepository; this.ownerRepository = ownerRepository; diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/SimpleSingleTest.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/SimpleSingleTest.java index a2799112..5660ecb6 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/SimpleSingleTest.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/SimpleSingleTest.java @@ -22,11 +22,10 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import software.xdev.spring.data.eclipse.store.helper.TestData; import software.xdev.spring.data.eclipse.store.helper.TestUtil; -import software.xdev.spring.data.eclipse.store.integration.isolated.IsolatedTestAnnotations; +import software.xdev.spring.data.eclipse.store.integration.TestConfiguration; import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.Customer; import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.CustomerAsRecord; import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.CustomerAsRecordRepository; @@ -35,22 +34,22 @@ import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.CustomerRepository; -@IsolatedTestAnnotations -@ContextConfiguration(classes = {SimpleTestConfiguration.class}) -class SimpleSingleTest +public abstract class SimpleSingleTest { private final CustomerRepository repository; private final CustomerAsRecordRepository recordRepository; - private final SimpleTestConfiguration configuration; + private final CustomerNotCrudRepository notCrudRepository; + private final TestConfiguration configuration; - @Autowired public SimpleSingleTest( final CustomerRepository repository, final CustomerAsRecordRepository recordRepository, - final SimpleTestConfiguration configuration) + final CustomerNotCrudRepository notCrudRepository, + final TestConfiguration configuration) { this.repository = repository; this.recordRepository = recordRepository; + this.notCrudRepository = notCrudRepository; this.configuration = configuration; } @@ -184,7 +183,7 @@ void testDoubleSaveAndFindAll() } @Test - void testBasicSaveAndFindAllWithNotCrudRepository(@Autowired final CustomerNotCrudRepository notCrudRepository) + void testBasicSaveAndFindAllWithNotCrudRepository() { final CustomerNotCrud customer = new CustomerNotCrud(TestData.FIRST_NAME, TestData.LAST_NAME); notCrudRepository.save(customer); diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/CustomerAsRecordLazyRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/CustomerAsRecordLazyRepository.java new file mode 100644 index 00000000..87389d17 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/CustomerAsRecordLazyRepository.java @@ -0,0 +1,28 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.lazy; + +import java.util.Optional; + +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.CustomerAsRecord; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.CustomerAsRecordRepository; +import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreCrudRepository; + + +public interface CustomerAsRecordLazyRepository + extends LazyEclipseStoreCrudRepository, CustomerAsRecordRepository +{ +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/CustomerLazyRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/CustomerLazyRepository.java new file mode 100644 index 00000000..ecd5b152 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/CustomerLazyRepository.java @@ -0,0 +1,34 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.lazy; + +import java.util.Optional; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; + +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.Customer; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.CustomerRepository; +import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreCrudRepository; +import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStorePagingAndSortingRepository; + + +public interface CustomerLazyRepository + extends LazyEclipseStoreCrudRepository, + LazyEclipseStorePagingAndSortingRepository, + CustomerRepository +{ +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/CustomerNotCrudLazyRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/CustomerNotCrudLazyRepository.java new file mode 100644 index 00000000..98d4d9bd --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/CustomerNotCrudLazyRepository.java @@ -0,0 +1,27 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.lazy; + +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.CustomerNotCrud; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.CustomerNotCrudRepository; +import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreRepository; + + +public interface CustomerNotCrudLazyRepository + extends LazyEclipseStoreRepository, CustomerNotCrudRepository +{ +} + diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/LazySimpleMultipleTest.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/LazySimpleMultipleTest.java new file mode 100644 index 00000000..f728c02f --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/LazySimpleMultipleTest.java @@ -0,0 +1,22 @@ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.lazy; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; + +import software.xdev.spring.data.eclipse.store.integration.isolated.IsolatedTestAnnotations; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.SimpleMultipleTest; + + +@IsolatedTestAnnotations +@ContextConfiguration(classes = {SimpleLazyTestConfiguration.class}) +public class LazySimpleMultipleTest extends SimpleMultipleTest +{ + @Autowired + public LazySimpleMultipleTest( + final CustomerLazyRepository customerRepository, + final OwnerLazyRepository ownerRepository, + final SimpleLazyTestConfiguration configuration) + { + super(customerRepository, ownerRepository, configuration); + } +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/LazySimpleSingleTest.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/LazySimpleSingleTest.java new file mode 100644 index 00000000..e03f3d95 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/LazySimpleSingleTest.java @@ -0,0 +1,23 @@ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.lazy; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; + +import software.xdev.spring.data.eclipse.store.integration.isolated.IsolatedTestAnnotations; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.SimpleSingleTest; + + +@IsolatedTestAnnotations +@ContextConfiguration(classes = {SimpleLazyTestConfiguration.class}) +public class LazySimpleSingleTest extends SimpleSingleTest +{ + @Autowired + public LazySimpleSingleTest( + final CustomerLazyRepository repository, + final CustomerAsRecordLazyRepository recordRepository, + final CustomerNotCrudLazyRepository notCrudRepository, + final SimpleLazyTestConfiguration configuration) + { + super(repository, recordRepository, notCrudRepository, configuration); + } +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/OwnerLazyRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/OwnerLazyRepository.java new file mode 100644 index 00000000..da58e2b1 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/OwnerLazyRepository.java @@ -0,0 +1,25 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.lazy; + +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.Owner; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.OwnerRepository; +import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreCrudRepository; + + +public interface OwnerLazyRepository extends LazyEclipseStoreCrudRepository, OwnerRepository +{ +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/SimpleTestConfiguration.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/SimpleLazyTestConfiguration.java similarity index 92% rename from spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/SimpleTestConfiguration.java rename to spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/SimpleLazyTestConfiguration.java index b7748c38..ed62d6b3 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/SimpleTestConfiguration.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/SimpleLazyTestConfiguration.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple; +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.lazy; import org.eclipse.serializer.reflect.ClassLoaderProvider; import org.eclipse.store.integrations.spring.boot.types.configuration.EclipseStoreProperties; @@ -27,10 +27,10 @@ @Configuration @EnableEclipseStoreRepositories -public class SimpleTestConfiguration extends TestConfiguration +public class SimpleLazyTestConfiguration extends TestConfiguration { @Autowired - protected SimpleTestConfiguration( + protected SimpleLazyTestConfiguration( final EclipseStoreProperties defaultEclipseStoreProperties, final EmbeddedStorageFoundationFactory defaultEclipseStoreProvider, final ClassLoaderProvider classLoaderProvider) diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/model/CustomerNotCrudRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/model/CustomerNotCrudRepository.java index e1701078..cbfb939b 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/model/CustomerNotCrudRepository.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/model/CustomerNotCrudRepository.java @@ -24,5 +24,5 @@ public interface CustomerNotCrudRepository extends Repository findAll(); - void save(CustomerNotCrud customer); + CustomerNotCrud save(CustomerNotCrud customer); } diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/model/CustomerRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/model/CustomerRepository.java index 07d191b8..b5e0c48f 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/model/CustomerRepository.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/model/CustomerRepository.java @@ -30,16 +30,6 @@ public interface CustomerRepository { Optional findByFirstName(String firstName); - Iterable findAllByLastName(String lastName); - @Override Page findAll(Pageable pageable); - - Page findAllByLastName(String lastName, Pageable pageable); - - List findByOrderByLastNameAsc(); - - Iterable findAllByLastName(String lastName, Sort sort); - - List findAllByFirstName(String lastName, Pageable pageable); } diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/CustomerAsRecordNonLazyRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/CustomerAsRecordNonLazyRepository.java new file mode 100644 index 00000000..0fc770c7 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/CustomerAsRecordNonLazyRepository.java @@ -0,0 +1,27 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.nonlazy; + +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.CustomerAsRecord; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.CustomerAsRecordRepository; +import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreCrudRepository; +import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreCrudRepository; + + +public interface CustomerAsRecordNonLazyRepository + extends EclipseStoreCrudRepository, CustomerAsRecordRepository +{ +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/CustomerNonLazyRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/CustomerNonLazyRepository.java new file mode 100644 index 00000000..44931f04 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/CustomerNonLazyRepository.java @@ -0,0 +1,31 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.nonlazy; + +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.Customer; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.CustomerRepository; +import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreCrudRepository; +import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStorePagingAndSortingRepository; +import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreCrudRepository; +import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStorePagingAndSortingRepository; + + +public interface CustomerNonLazyRepository + extends EclipseStoreCrudRepository, + EclipseStorePagingAndSortingRepository, + CustomerRepository +{ +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/CustomerNotCrudNonLazyRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/CustomerNotCrudNonLazyRepository.java new file mode 100644 index 00000000..c98fb18d --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/CustomerNotCrudNonLazyRepository.java @@ -0,0 +1,28 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.nonlazy; + +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.CustomerNotCrud; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.CustomerNotCrudRepository; +import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository; +import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreRepository; + + +public interface CustomerNotCrudNonLazyRepository + extends EclipseStoreRepository, CustomerNotCrudRepository +{ +} + diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/NonLazySimpleMultipleTest.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/NonLazySimpleMultipleTest.java new file mode 100644 index 00000000..cd38aa6c --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/NonLazySimpleMultipleTest.java @@ -0,0 +1,22 @@ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.nonlazy; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; + +import software.xdev.spring.data.eclipse.store.integration.isolated.IsolatedTestAnnotations; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.SimpleMultipleTest; + + +@IsolatedTestAnnotations +@ContextConfiguration(classes = {SimpleNonLazyTestConfiguration.class}) +public class NonLazySimpleMultipleTest extends SimpleMultipleTest +{ + @Autowired + public NonLazySimpleMultipleTest( + final CustomerNonLazyRepository customerRepository, + final OwnerNonLazyRepository ownerRepository, + final SimpleNonLazyTestConfiguration configuration) + { + super(customerRepository, ownerRepository, configuration); + } +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/NonLazySimpleSingleTest.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/NonLazySimpleSingleTest.java new file mode 100644 index 00000000..713a891d --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/NonLazySimpleSingleTest.java @@ -0,0 +1,23 @@ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.nonlazy; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; + +import software.xdev.spring.data.eclipse.store.integration.isolated.IsolatedTestAnnotations; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.SimpleSingleTest; + + +@IsolatedTestAnnotations +@ContextConfiguration(classes = {SimpleNonLazyTestConfiguration.class}) +public class NonLazySimpleSingleTest extends SimpleSingleTest +{ + @Autowired + public NonLazySimpleSingleTest( + final CustomerNonLazyRepository repository, + final CustomerAsRecordNonLazyRepository recordRepository, + final CustomerNotCrudNonLazyRepository notCrudRepository, + final SimpleNonLazyTestConfiguration configuration) + { + super(repository, recordRepository, notCrudRepository, configuration); + } +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/OwnerNonLazyRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/OwnerNonLazyRepository.java new file mode 100644 index 00000000..6ab35324 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/OwnerNonLazyRepository.java @@ -0,0 +1,25 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.nonlazy; + +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.Owner; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.OwnerRepository; +import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreCrudRepository; + + +public interface OwnerNonLazyRepository extends EclipseStoreCrudRepository, OwnerRepository +{ +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/SimpleNonLazyTestConfiguration.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/SimpleNonLazyTestConfiguration.java new file mode 100644 index 00000000..32207e9c --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/SimpleNonLazyTestConfiguration.java @@ -0,0 +1,40 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.nonlazy; + +import org.eclipse.serializer.reflect.ClassLoaderProvider; +import org.eclipse.store.integrations.spring.boot.types.configuration.EclipseStoreProperties; +import org.eclipse.store.integrations.spring.boot.types.factories.EmbeddedStorageFoundationFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; + +import software.xdev.spring.data.eclipse.store.integration.TestConfiguration; +import software.xdev.spring.data.eclipse.store.repository.config.EnableEclipseStoreRepositories; + + +@Configuration +@EnableEclipseStoreRepositories +public class SimpleNonLazyTestConfiguration extends TestConfiguration +{ + @Autowired + protected SimpleNonLazyTestConfiguration( + final EclipseStoreProperties defaultEclipseStoreProperties, + final EmbeddedStorageFoundationFactory defaultEclipseStoreProvider, + final ClassLoaderProvider classLoaderProvider) + { + super(defaultEclipseStoreProperties, defaultEclipseStoreProvider, classLoaderProvider); + } +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/interfaces/CustomerEclipseStoreListPagingAndSortingRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/interfaces/CustomerEclipseStoreListPagingAndSortingRepository.java index 575042ad..abb641ef 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/interfaces/CustomerEclipseStoreListPagingAndSortingRepository.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/interfaces/CustomerEclipseStoreListPagingAndSortingRepository.java @@ -15,10 +15,10 @@ */ package software.xdev.spring.data.eclipse.store.integration.shared.repositories.interfaces; -import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreListPagingAndSortingRepositoryRepository; +import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreListPagingAndSortingRepository; public interface CustomerEclipseStoreListPagingAndSortingRepository extends - EclipseStoreListPagingAndSortingRepositoryRepository + EclipseStoreListPagingAndSortingRepository { } diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/interfaces/CustomerEclipseStorePagingAndSortingRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/interfaces/CustomerEclipseStorePagingAndSortingRepository.java index 53710546..6914d987 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/interfaces/CustomerEclipseStorePagingAndSortingRepository.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/interfaces/CustomerEclipseStorePagingAndSortingRepository.java @@ -15,10 +15,10 @@ */ package software.xdev.spring.data.eclipse.store.integration.shared.repositories.interfaces; -import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStorePagingAndSortingRepositoryRepository; +import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStorePagingAndSortingRepository; public interface CustomerEclipseStorePagingAndSortingRepository - extends EclipseStorePagingAndSortingRepositoryRepository + extends EclipseStorePagingAndSortingRepository { } From 86973047797bbd6fc1aa7ceaeb75f94ca3bd4326 Mon Sep 17 00:00:00 2001 From: JohannesRabauer Date: Mon, 9 Dec 2024 14:17:27 +0100 Subject: [PATCH 49/54] Lazy References in Repositories are now real ES Lazies --- .../store/repository/root/VersionedRoot.java | 1 - .../repository/root/v2_4/LazyEntityData.java | 9 ++++++--- .../tests/simple/lazy/LazySimpleMultipleTest.java | 15 +++++++++++++++ .../tests/simple/lazy/LazySimpleSingleTest.java | 15 +++++++++++++++ .../simple/nonlazy/NonLazySimpleMultipleTest.java | 15 +++++++++++++++ .../simple/nonlazy/NonLazySimpleSingleTest.java | 15 +++++++++++++++ 6 files changed, 66 insertions(+), 4 deletions(-) diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/VersionedRoot.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/VersionedRoot.java index fd435a55..e32f0a01 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/VersionedRoot.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/VersionedRoot.java @@ -44,7 +44,6 @@ public VersionedRoot() public VersionedRoot(final Root rootDataV1) { this.rootDataV1 = rootDataV1; - this.rootDataV2 = new RootDataV2(); this.rootDataV2_4 = new RootDataV2_4(); if(rootDataV1 != null) { diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/LazyEntityData.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/LazyEntityData.java index d4b805cf..5a1bf23f 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/LazyEntityData.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/LazyEntityData.java @@ -24,7 +24,6 @@ import org.eclipse.serializer.reference.Referencing; import software.xdev.spring.data.eclipse.store.core.IdentitySet; -import software.xdev.spring.data.eclipse.store.repository.lazy.SpringDataEclipseStoreLazy; import software.xdev.spring.data.eclipse.store.repository.support.id.IdGetter; @@ -131,7 +130,9 @@ public Collection ensureEntityAndReturnObjectsToStore(final T entityToSt Collection listToSave = List.of(); if(this.idGetter == null && !this.containsEntity(entityToStore)) { - this.entities.add(SpringDataEclipseStoreLazy.build(entityToStore)); + // Does not create a SpringDataEclipseStore.Lazy Instance, but a EclipseStore.Lazy because this is + // outside the scope of the SpringDataEclipseStore.Lazy. No conversion is taking place. + this.entities.add(Lazy.Reference(entityToStore)); listToSave = this.getObjectsToStore(); } if(this.idGetter != null) @@ -140,7 +141,9 @@ public Collection ensureEntityAndReturnObjectsToStore(final T entityToSt if(existingEntity == null || existingEntity.get() != entityToStore) { this.entities.remove(existingEntity); - final SpringDataEclipseStoreLazy newLazyInstance = SpringDataEclipseStoreLazy.build(entityToStore); + // Does not create a SpringDataEclipseStore.Lazy Instance, but a EclipseStore.Lazy because this is + // outside the scope of the SpringDataEclipseStore.Lazy. No conversion is taking place. + final Lazy newLazyInstance = Lazy.Reference(entityToStore); this.entities.add(newLazyInstance); this.entitiesById.put(this.idGetter.getId(entityToStore), newLazyInstance); listToSave = this.getObjectsToStore(); diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/LazySimpleMultipleTest.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/LazySimpleMultipleTest.java index f728c02f..2f593df9 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/LazySimpleMultipleTest.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/LazySimpleMultipleTest.java @@ -1,3 +1,18 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.lazy; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/LazySimpleSingleTest.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/LazySimpleSingleTest.java index e03f3d95..f849bfb3 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/LazySimpleSingleTest.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/LazySimpleSingleTest.java @@ -1,3 +1,18 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.lazy; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/NonLazySimpleMultipleTest.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/NonLazySimpleMultipleTest.java index cd38aa6c..084fe2e3 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/NonLazySimpleMultipleTest.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/NonLazySimpleMultipleTest.java @@ -1,3 +1,18 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.nonlazy; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/NonLazySimpleSingleTest.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/NonLazySimpleSingleTest.java index 713a891d..65451986 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/NonLazySimpleSingleTest.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/NonLazySimpleSingleTest.java @@ -1,3 +1,18 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.nonlazy; import org.springframework.beans.factory.annotation.Autowired; From 2c36144dccd2ce71e4132d97e7644db1db790c93 Mon Sep 17 00:00:00 2001 From: JohannesRabauer Date: Mon, 9 Dec 2024 14:49:02 +0100 Subject: [PATCH 50/54] Expanded Test to look for lazy implementation --- .../store/repository/EclipseStoreStorage.java | 9 ++++++++ .../repository/root/v2_4/LazyEntityData.java | 5 +++++ .../isolated/tests/lazy/LazyTest.java | 22 +++++++++++++------ 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreStorage.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreStorage.java index 44e171c9..b302d5b3 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreStorage.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreStorage.java @@ -498,4 +498,13 @@ public ReadWriteLock getReadWriteLock() { return this.readWriteLock; } + + /** + * Warning! Please be very cautious if you access the root object. + * This should only be done if absolutely necessary! + */ + public VersionedRoot getRoot() + { + return root; + } } diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/LazyEntityData.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/LazyEntityData.java index 5a1bf23f..d16da334 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/LazyEntityData.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/LazyEntityData.java @@ -186,4 +186,9 @@ public Collection removeAllEntitiesAndReturnObjectsToStore() this.entitiesById.clear(); return this.getObjectsToStore(); } + + public HashMap> getNativeLazyEntitiesById() + { + return entitiesById; + } } diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/LazyTest.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/LazyTest.java index b0b74e89..46771799 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/LazyTest.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/LazyTest.java @@ -19,6 +19,7 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.List; import java.util.Optional; @@ -37,6 +38,8 @@ import software.xdev.spring.data.eclipse.store.helper.TestUtil; import software.xdev.spring.data.eclipse.store.integration.isolated.IsolatedTestAnnotations; import software.xdev.spring.data.eclipse.store.repository.lazy.SpringDataEclipseStoreLazy; +import software.xdev.spring.data.eclipse.store.repository.root.v2_4.EntityData; +import software.xdev.spring.data.eclipse.store.repository.root.v2_4.LazyEntityData; @SuppressWarnings("checkstyle:MethodName") @@ -302,7 +305,6 @@ void lazyClearBeforeSave() } @Test - @Disabled("This should work at some point. At least a warning should be displayed.") void lazyUseEclipseStoreLazy(@Autowired final ObjectWithLazyRepository repository) { final ObjectWithLazy newLazy = new ObjectWithLazy<>(); @@ -515,19 +517,25 @@ void simpleEntityWithIdLazyWrappedRepository_FindById( void simpleEntityWithIdLazyRepository_FindById(@Autowired final SimpleEntityWithIdLazyRepository repository) { final SimpleEntityWithId objectToStore1 = new SimpleEntityWithId(TestData.DUMMY_STRING); - repository.save(objectToStore1); + final Long object1Id = repository.save(objectToStore1).getId(); final SimpleEntityWithId objectToStore2 = new SimpleEntityWithId(TestData.DUMMY_STRING); - repository.save(objectToStore2); - - final List all = repository.findAll(); + final Long object2Id = repository.save(objectToStore2).getId(); TestUtil.doBeforeAndAfterRestartOfDatastore( this.configuration, () -> { - final Optional reloadedObject = - repository.findById(all.get(0).getId()); + LazyReferenceManager.get().cleanUp(); + final Optional reloadedObject = repository.findById(object1Id); Assertions.assertTrue(reloadedObject.isPresent()); } ); + final EntityData entityData = this.configuration.getStorageInstance() + .getRoot() + .getCurrentRootData() + .getEntityData(SimpleEntityWithId.class); + final HashMap> lazyEntitiesById = + ((LazyEntityData)entityData).getNativeLazyEntitiesById(); + Assertions.assertTrue(lazyEntitiesById.get(object1Id).isLoaded()); + Assertions.assertFalse(lazyEntitiesById.get(object2Id).isLoaded()); } } From 2eedf7090a4830bbb48880d41988002e477d76f7 Mon Sep 17 00:00:00 2001 From: JohannesRabauer Date: Mon, 9 Dec 2024 15:12:33 +0100 Subject: [PATCH 51/54] Add LazyRepo demo --- .gitignore | 1 + .../eclipse/store/demo/lazy/Customer.java | 31 +++++++++ .../store/demo/lazy/CustomerRepository.java | 8 +++ .../store/demo/lazy/LazyConfiguration.java | 56 +++++++++++++++ .../store/demo/lazy/LazyDemoApplication.java | 69 +++++++++++++++++++ .../data/eclipse/store/demo/lazy/Pet.java | 32 +++++++++ .../store/demo/lazy/PetRepository.java | 8 +++ .../lazy/complex/LazyDemoApplicationTest.java | 39 +++++++++++ 8 files changed, 244 insertions(+) create mode 100644 spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/Customer.java create mode 100644 spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/CustomerRepository.java create mode 100644 spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/LazyConfiguration.java create mode 100644 spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/LazyDemoApplication.java create mode 100644 spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/Pet.java create mode 100644 spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/PetRepository.java create mode 100644 spring-data-eclipse-store-demo/src/test/java/software/xdev/spring/data/eclipse/store/demo/lazy/complex/LazyDemoApplicationTest.java diff --git a/.gitignore b/.gitignore index 3370dfc0..5de618cb 100644 --- a/.gitignore +++ b/.gitignore @@ -67,6 +67,7 @@ spring-data-eclipse-store-demo/storage spring-data-eclipse-store-demo/storage-person spring-data-eclipse-store-demo/storage-invoice spring-data-eclipse-store-demo/storage-complex +spring-data-eclipse-store-demo/storage-lazy spring-data-eclipse-store-jpa/storage-eclipsestore spring-data-eclipse-store-jpa/storage-h2.mv.db spring-data-eclipse-store-jpa/storage-h2.trace.db diff --git a/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/Customer.java b/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/Customer.java new file mode 100644 index 00000000..191e38c8 --- /dev/null +++ b/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/Customer.java @@ -0,0 +1,31 @@ +package software.xdev.spring.data.eclipse.store.demo.lazy; + +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; + +import org.springframework.data.annotation.Id; + + +public class Customer +{ + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private String id; + + private final String firstName; + private final String lastName; + + public Customer(final String firstName, final String lastName) + { + this.firstName = firstName; + this.lastName = lastName; + } + + @Override + public String toString() + { + return String.format( + "Customer[id=%s, firstName='%s', lastName='%s']", + this.id, this.firstName, this.lastName); + } +} diff --git a/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/CustomerRepository.java b/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/CustomerRepository.java new file mode 100644 index 00000000..7c0edc1d --- /dev/null +++ b/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/CustomerRepository.java @@ -0,0 +1,8 @@ +package software.xdev.spring.data.eclipse.store.demo.lazy; + +import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreCrudRepository; + + +public interface CustomerRepository extends LazyEclipseStoreCrudRepository +{ +} diff --git a/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/LazyConfiguration.java b/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/LazyConfiguration.java new file mode 100644 index 00000000..7c73884b --- /dev/null +++ b/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/LazyConfiguration.java @@ -0,0 +1,56 @@ +package software.xdev.spring.data.eclipse.store.demo.lazy; + +import java.nio.file.Path; + +import org.eclipse.serializer.reflect.ClassLoaderProvider; +import org.eclipse.store.integrations.spring.boot.types.configuration.EclipseStoreProperties; +import org.eclipse.store.integrations.spring.boot.types.factories.EmbeddedStorageFoundationFactory; +import org.eclipse.store.storage.embedded.types.EmbeddedStorage; +import org.eclipse.store.storage.embedded.types.EmbeddedStorageFoundation; +import org.eclipse.store.storage.types.Storage; +import org.springframework.beans.factory.ObjectProvider; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.transaction.TransactionManagerCustomizers; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.transaction.PlatformTransactionManager; + +import software.xdev.spring.data.eclipse.store.demo.dual.storage.person.PersistencePersonConfiguration; +import software.xdev.spring.data.eclipse.store.repository.config.EclipseStoreClientConfiguration; +import software.xdev.spring.data.eclipse.store.repository.config.EnableEclipseStoreRepositories; + + +@Configuration +@EnableEclipseStoreRepositories +public class LazyConfiguration extends EclipseStoreClientConfiguration +{ + + public static final String STORAGE_PATH = "storage-lazy"; + + @Autowired + public LazyConfiguration( + final EclipseStoreProperties defaultEclipseStoreProperties, + final EmbeddedStorageFoundationFactory defaultEclipseStoreProvider, + final ClassLoaderProvider classLoaderProvider + ) + { + super(defaultEclipseStoreProperties, defaultEclipseStoreProvider, classLoaderProvider); + } + /** + * This is one option how to configure the {@link EmbeddedStorageFoundation}. + *

+ * We create a completely new foundation. That means that all configuration (e.g. properties) are not used here. + * With this method you have complete control over the configuration. + *

+ * Another example: {@link PersistencePersonConfiguration#createEmbeddedStorageFoundation()} + */ + @Override + public EmbeddedStorageFoundation createEmbeddedStorageFoundation() + { + final EmbeddedStorageFoundation storageFoundation = + EmbeddedStorage.Foundation(Storage.Configuration(Storage.FileProvider(Path.of(STORAGE_PATH)))); + // This is only needed, if a different ClassLoader is used (e.g. when using spring-dev-tools) + storageFoundation.getConnectionFoundation().setClassLoaderProvider(getClassLoaderProvider()); + return storageFoundation; + } +} diff --git a/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/LazyDemoApplication.java b/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/LazyDemoApplication.java new file mode 100644 index 00000000..abc22e42 --- /dev/null +++ b/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/LazyDemoApplication.java @@ -0,0 +1,69 @@ +/* + * Copyright 2012-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package software.xdev.spring.data.eclipse.store.demo.lazy; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +import software.xdev.spring.data.eclipse.store.repository.config.EnableEclipseStoreRepositories; + + +@SpringBootApplication +public class LazyDemoApplication implements CommandLineRunner +{ + private static final Logger LOG = LoggerFactory.getLogger(LazyDemoApplication.class); + private final CustomerRepository customerRepository; + private final PetRepository petRepository; + + public LazyDemoApplication( + final CustomerRepository customerRepository, + final PetRepository petRepository + ) + { + this.customerRepository = customerRepository; + this.petRepository = petRepository; + } + + public static void main(final String[] args) + { + SpringApplication.run(LazyDemoApplication.class, args); + } + + @Override + public void run(final String... args) + { + this.customerRepository.deleteAll(); + + // save a couple of customers + this.customerRepository.save(new Customer("Stevie", "Nicks")); + this.customerRepository.save(new Customer("Mick", "Fleetwood")); + + // fetch all customers + LOG.info("Customers found with findAll():"); + this.customerRepository.findAll().forEach(c -> LOG.info(c.toString())); + + // save a pet + this.petRepository.save(new Pet("1", "Peter", 2)); + + // fetch all pets + LOG.info("Pets found with findAll():"); + this.petRepository.findAll().forEach(p -> LOG.info(p.toString())); + } +} diff --git a/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/Pet.java b/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/Pet.java new file mode 100644 index 00000000..6a36915b --- /dev/null +++ b/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/Pet.java @@ -0,0 +1,32 @@ +package software.xdev.spring.data.eclipse.store.demo.lazy; + +import org.springframework.data.annotation.Id; + + +public class Pet +{ + @Id + private String id; + + private String name; + private Integer age; + + public Pet() + { + } + + public Pet(final String id, final String name, final Integer age) + { + this.id = id; + this.name = name; + this.age = age; + } + + @Override + public String toString() + { + return String.format( + "Pet[id=%s, name='%s', age='%s']", + this.id, this.name, this.age); + } +} diff --git a/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/PetRepository.java b/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/PetRepository.java new file mode 100644 index 00000000..2cba129d --- /dev/null +++ b/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/PetRepository.java @@ -0,0 +1,8 @@ +package software.xdev.spring.data.eclipse.store.demo.lazy; + +import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreCrudRepository; + + +public interface PetRepository extends LazyEclipseStoreCrudRepository +{ +} diff --git a/spring-data-eclipse-store-demo/src/test/java/software/xdev/spring/data/eclipse/store/demo/lazy/complex/LazyDemoApplicationTest.java b/spring-data-eclipse-store-demo/src/test/java/software/xdev/spring/data/eclipse/store/demo/lazy/complex/LazyDemoApplicationTest.java new file mode 100644 index 00000000..f6a7cd6f --- /dev/null +++ b/spring-data-eclipse-store-demo/src/test/java/software/xdev/spring/data/eclipse/store/demo/lazy/complex/LazyDemoApplicationTest.java @@ -0,0 +1,39 @@ +package software.xdev.spring.data.eclipse.store.demo.lazy.complex; + +import java.io.File; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; + +import software.xdev.spring.data.eclipse.store.demo.TestUtil; +import software.xdev.spring.data.eclipse.store.demo.lazy.LazyConfiguration; +import software.xdev.spring.data.eclipse.store.demo.lazy.LazyDemoApplication; +import software.xdev.spring.data.eclipse.store.repository.config.EclipseStoreClientConfiguration; + + +@SpringBootTest(classes = LazyDemoApplication.class) +class LazyDemoApplicationTest +{ + private final EclipseStoreClientConfiguration configuration; + + @Autowired + public LazyDemoApplicationTest(final LazyConfiguration configuration) + { + this.configuration = configuration; + } + + @BeforeAll + static void clearPreviousData() + { + TestUtil.deleteDirectory(new File("./" + LazyConfiguration.STORAGE_PATH)); + } + + @Test + void checkPossibilityToSimplyStartAndRestartApplication() + { + this.configuration.getStorageInstance().stop(); + LazyDemoApplication.main(new String[]{}); + } +} From c94f087447d4713d8db5e4ceeb62756003dcc099 Mon Sep 17 00:00:00 2001 From: JohannesRabauer Date: Mon, 9 Dec 2024 15:49:26 +0100 Subject: [PATCH 52/54] Added lazy documentation --- CHANGELOG.md | 1 + README.md | 1 + docs/modules/ROOT/pages/features/lazies.adoc | 28 ++++++++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 171ab3c4..90f08446 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ * Updated org.springframework.boot.version to v3.4.0 * Updated EclipseStore to v2.0.0 +* Implemented Lazy Repositories with ``LazyEclipseStoreRepository`` # 2.3.1 diff --git a/README.md b/README.md index e763ae1a..e177eb9b 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,7 @@ the [demos](./spring-data-eclipse-store-demo): * [Simple demo](https://github.com/xdev-software/spring-data-eclipse-store/tree/develop/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/simple) * [Complex demo](https://github.com/xdev-software/spring-data-eclipse-store/tree/develop/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/complex) +* [Lazy demo](https://github.com/xdev-software/spring-data-eclipse-store/tree/develop/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy) * [Demo with coexisting JPA](https://github.com/xdev-software/spring-data-eclipse-store/tree/develop/spring-data-eclipse-store-jpa/src/main/java/software/xdev/spring/data/eclipse/store/jpa) * [Dual storage demo](https://github.com/xdev-software/spring-data-eclipse-store/tree/develop/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/dual/storage) diff --git a/docs/modules/ROOT/pages/features/lazies.adoc b/docs/modules/ROOT/pages/features/lazies.adoc index 80a04834..ba79f922 100644 --- a/docs/modules/ROOT/pages/features/lazies.adoc +++ b/docs/modules/ROOT/pages/features/lazies.adoc @@ -31,6 +31,34 @@ public class Owner extends Person //... ---- +== Repositories + +Entities in a repository are by default **not lazy**. +But we made it as easy as possible for you to make these entities lazy: Instead of extending the ``EclipseStoreRepository`` (or any similar class from the ``software.xdev.spring.data.eclipse.store.repository.interfaces``-Package), you simply extend the ``LazyEclipseStoreRepository``. + +=== https://github.com/xdev-software/spring-data-eclipse-store/tree/develop/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/CustomerRepository.java[Example from lazy demo] + +[source,java,title="https://github.com/xdev-software/spring-data-eclipse-store/tree/develop/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/simple/CustomerRepository.java[Before (not lazy)]"] +---- +public interface CustomerRepository extends CrudRepository +{ +} +---- + +[source,java,title="https://github.com/xdev-software/spring-data-eclipse-store/tree/develop/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/CustomerRepository.java[After (lazy)]"] +---- +public interface CustomerRepository extends LazyEclipseStoreCrudRepository +{ +} +---- + +Every instance of the ``Customer``-Entities are now wrapped in a https://docs.eclipsestore.io/manual/storage/loading-data/lazy-loading/index.html[``Lazy``-Reference]. +That means that these objects are **only loaded from the storage, if they are needed** e.g. when ``findAll`` is called. + +The method **``findById`` only loads the entities with the corresponding IDs**, because a separate list with all ids is stored. +But if any method like **``findByName`` or ``findByChild`` is used, all objects are loaded** from the storage. +This is currently the only way to get the actual values of the entities. + == Internals SpringDataEclipseStoreLazies work as a proxy for the EclipseStore-Lazies. From 7c7fbe4cf7e380629c5a148f0fce8cd18fa782ea Mon Sep 17 00:00:00 2001 From: JohannesRabauer Date: Mon, 9 Dec 2024 16:01:24 +0100 Subject: [PATCH 53/54] Checkstyle fixes --- docs/modules/ROOT/pages/features/lazies.adoc | 2 +- .../eclipse/store/demo/lazy/LazyConfiguration.java | 6 +----- .../eclipse/store/demo/lazy/LazyDemoApplication.java | 4 +--- .../eclipse/store/repository/EclipseStoreStorage.java | 4 ++-- .../config/EclipseStoreClientConfiguration.java | 7 +++---- .../lazy/LazyEclipseStoreCustomRepository.java | 1 - .../lazy/LazyEclipseStoreQueryByExampleExecutor.java | 1 - .../lazy/SpringDataEclipseStoreLazyBinaryHandler.java | 10 +++++----- .../eclipse/store/repository/root/VersionedRoot.java | 2 ++ .../eclipse/store/repository/root/v2_4/EntityData.java | 3 --- .../store/repository/root/v2_4/NonLazyEntityData.java | 1 - .../store/repository/root/v2_4/RootDataV2_4.java | 2 +- .../support/EclipseStoreRepositoryFactory.java | 6 ++---- .../isolated/tests/simple/SimpleMultipleTest.java | 4 ---- .../isolated/tests/simple/SimpleSingleTest.java | 6 +++--- .../simple/lazy/CustomerAsRecordLazyRepository.java | 3 +-- .../tests/simple/lazy/CustomerLazyRepository.java | 5 ----- .../tests/simple/model/CustomerRepository.java | 2 -- .../nonlazy/CustomerAsRecordNonLazyRepository.java | 1 - .../simple/nonlazy/CustomerNonLazyRepository.java | 2 -- .../nonlazy/CustomerNotCrudNonLazyRepository.java | 2 -- 21 files changed, 22 insertions(+), 52 deletions(-) diff --git a/docs/modules/ROOT/pages/features/lazies.adoc b/docs/modules/ROOT/pages/features/lazies.adoc index ba79f922..371bd903 100644 --- a/docs/modules/ROOT/pages/features/lazies.adoc +++ b/docs/modules/ROOT/pages/features/lazies.adoc @@ -27,7 +27,7 @@ public class Owner extends Person { private String address; - private Lazy> pets = SpringDataEclipseStoreLazy.build(new ArrayList<>()); + private final Lazy> pets = SpringDataEclipseStoreLazy.build(new ArrayList<>()); //... ---- diff --git a/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/LazyConfiguration.java b/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/LazyConfiguration.java index 7c73884b..a17df36c 100644 --- a/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/LazyConfiguration.java +++ b/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/LazyConfiguration.java @@ -8,12 +8,8 @@ import org.eclipse.store.storage.embedded.types.EmbeddedStorage; import org.eclipse.store.storage.embedded.types.EmbeddedStorageFoundation; import org.eclipse.store.storage.types.Storage; -import org.springframework.beans.factory.ObjectProvider; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.transaction.TransactionManagerCustomizers; -import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.transaction.PlatformTransactionManager; import software.xdev.spring.data.eclipse.store.demo.dual.storage.person.PersistencePersonConfiguration; import software.xdev.spring.data.eclipse.store.repository.config.EclipseStoreClientConfiguration; @@ -50,7 +46,7 @@ public EmbeddedStorageFoundation createEmbeddedStorageFoundation() final EmbeddedStorageFoundation storageFoundation = EmbeddedStorage.Foundation(Storage.Configuration(Storage.FileProvider(Path.of(STORAGE_PATH)))); // This is only needed, if a different ClassLoader is used (e.g. when using spring-dev-tools) - storageFoundation.getConnectionFoundation().setClassLoaderProvider(getClassLoaderProvider()); + storageFoundation.getConnectionFoundation().setClassLoaderProvider(this.getClassLoaderProvider()); return storageFoundation; } } diff --git a/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/LazyDemoApplication.java b/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/LazyDemoApplication.java index abc22e42..6502081e 100644 --- a/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/LazyDemoApplication.java +++ b/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/LazyDemoApplication.java @@ -21,9 +21,7 @@ import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; - -import software.xdev.spring.data.eclipse.store.repository.config.EnableEclipseStoreRepositories; - + @SpringBootApplication public class LazyDemoApplication implements CommandLineRunner diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreStorage.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreStorage.java index b302d5b3..a92213b7 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreStorage.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreStorage.java @@ -54,7 +54,7 @@ import software.xdev.spring.data.eclipse.store.repository.support.reposyncer.SimpleRepositorySynchronizer; -@SuppressWarnings("java:S119") +@SuppressWarnings({"java:S119", "PMD.GodClass"}) public class EclipseStoreStorage implements EntityListProvider, IdManagerProvider, @@ -505,6 +505,6 @@ public ReadWriteLock getReadWriteLock() */ public VersionedRoot getRoot() { - return root; + return this.root; } } diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/config/EclipseStoreClientConfiguration.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/config/EclipseStoreClientConfiguration.java index 7ec64a3d..b75a22b4 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/config/EclipseStoreClientConfiguration.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/config/EclipseStoreClientConfiguration.java @@ -15,10 +15,10 @@ */ package software.xdev.spring.data.eclipse.store.repository.config; -import org.eclipse.serializer.reflect.ClassLoaderProvider; import jakarta.validation.Validation; import jakarta.validation.Validator; +import org.eclipse.serializer.reflect.ClassLoaderProvider; import org.eclipse.store.integrations.spring.boot.types.configuration.EclipseStoreProperties; import org.eclipse.store.integrations.spring.boot.types.factories.EmbeddedStorageFoundationFactory; import org.eclipse.store.storage.embedded.types.EmbeddedStorageFoundation; @@ -34,7 +34,6 @@ import org.springframework.context.event.ContextClosedEvent; import org.springframework.context.event.EventListener; import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.transaction.TransactionManager; import software.xdev.spring.data.eclipse.store.repository.EclipseStoreStorage; import software.xdev.spring.data.eclipse.store.transactions.EclipseStoreTransactionManager; @@ -108,7 +107,7 @@ public EmbeddedStorageFoundationFactory getStoreProvider() public ClassLoaderProvider getClassLoaderProvider() { - return classLoaderProvider; + return this.classLoaderProvider; } /** @@ -134,7 +133,7 @@ public PlatformTransactionManager transactionManager( final ObjectProvider transactionManagerCustomizers) { final EclipseStoreTransactionManager tm = this.getTransactionManagerInstance(); - transactionManagerCustomizers.ifAvailable(customizers -> customizers.customize((TransactionManager)tm)); + transactionManagerCustomizers.ifAvailable(customizers -> customizers.customize(tm)); return tm; } diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreCustomRepository.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreCustomRepository.java index a251c05b..14feb516 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreCustomRepository.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreCustomRepository.java @@ -15,7 +15,6 @@ */ package software.xdev.spring.data.eclipse.store.repository.interfaces.lazy; -import org.eclipse.serializer.reference.Lazy; import org.springframework.data.repository.NoRepositoryBean; import org.springframework.data.repository.Repository; diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreQueryByExampleExecutor.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreQueryByExampleExecutor.java index be1ccfed..d4ea57fd 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreQueryByExampleExecutor.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/lazy/LazyEclipseStoreQueryByExampleExecutor.java @@ -15,7 +15,6 @@ */ package software.xdev.spring.data.eclipse.store.repository.interfaces.lazy; -import org.eclipse.serializer.reference.Lazy; import org.springframework.data.repository.NoRepositoryBean; import org.springframework.data.repository.query.QueryByExampleExecutor; diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/lazy/SpringDataEclipseStoreLazyBinaryHandler.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/lazy/SpringDataEclipseStoreLazyBinaryHandler.java index a6223a84..439b75c8 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/lazy/SpringDataEclipseStoreLazyBinaryHandler.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/lazy/SpringDataEclipseStoreLazyBinaryHandler.java @@ -154,7 +154,7 @@ private void updateStateT( } @Override - public final void complete( + public void complete( final Binary data, final SpringDataEclipseStoreLazy.Default instance, final PersistenceLoadHandler handler @@ -164,25 +164,25 @@ public final void complete( } @Override - public final boolean hasPersistedReferences() + public boolean hasPersistedReferences() { return true; } @Override - public final boolean hasPersistedVariableLength() + public boolean hasPersistedVariableLength() { return false; } @Override - public final boolean hasVaryingPersistedLengthInstances() + public boolean hasVaryingPersistedLengthInstances() { return false; } @Override - public final void iterateLoadableReferences( + public void iterateLoadableReferences( final Binary data, final PersistenceReferenceLoader iterator ) diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/VersionedRoot.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/VersionedRoot.java index e32f0a01..5df1f28c 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/VersionedRoot.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/VersionedRoot.java @@ -31,6 +31,7 @@ public class VersionedRoot implements Versioned private RootDataV2 rootDataV2; + @SuppressWarnings("checkstyle:MemberName") private final RootDataV2_4 rootDataV2_4; public VersionedRoot() @@ -63,6 +64,7 @@ public Root getRootDataV1() /** * @deprecated and is only used in tests */ + @SuppressWarnings("DeprecatedIsStillUsed") @Deprecated public void setRootDataV2(final RootDataV2 rootDataV2) { diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/EntityData.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/EntityData.java index ad8310de..609dc1c1 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/EntityData.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/EntityData.java @@ -16,11 +16,8 @@ package software.xdev.spring.data.eclipse.store.repository.root.v2_4; import java.util.Collection; -import java.util.HashMap; -import java.util.function.Function; import java.util.stream.Stream; -import software.xdev.spring.data.eclipse.store.core.IdentitySet; import software.xdev.spring.data.eclipse.store.repository.support.id.IdGetter; diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/NonLazyEntityData.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/NonLazyEntityData.java index cbcf2b2b..d71be4f7 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/NonLazyEntityData.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/NonLazyEntityData.java @@ -18,7 +18,6 @@ import java.util.Collection; import java.util.HashMap; import java.util.List; -import java.util.function.Function; import java.util.stream.Stream; import software.xdev.spring.data.eclipse.store.core.IdentitySet; diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/RootDataV2_4.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/RootDataV2_4.java index 07697650..3b5288d2 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/RootDataV2_4.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/RootDataV2_4.java @@ -24,7 +24,7 @@ /** * This is the actually stored object. */ -@SuppressWarnings("java:S119") +@SuppressWarnings({"java:S119", "checkstyle:TypeName"}) public class RootDataV2_4 { private final Map> entityLists; diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/EclipseStoreRepositoryFactory.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/EclipseStoreRepositoryFactory.java index 795f01ee..6d1e4c00 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/EclipseStoreRepositoryFactory.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/EclipseStoreRepositoryFactory.java @@ -20,7 +20,6 @@ import jakarta.annotation.Nonnull; import jakarta.validation.Validator; -import org.eclipse.serializer.reference.Lazy; import org.springframework.data.mapping.model.BasicPersistentEntity; import org.springframework.data.repository.core.EntityInformation; import org.springframework.data.repository.core.RepositoryInformation; @@ -35,7 +34,6 @@ import org.springframework.transaction.PlatformTransactionManager; import software.xdev.spring.data.eclipse.store.repository.EclipseStoreStorage; -import software.xdev.spring.data.eclipse.store.repository.StorageCommunicator; import software.xdev.spring.data.eclipse.store.repository.SupportedChecker; import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository; import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreCrudRepository; @@ -107,7 +105,7 @@ private WorkingCopier createWorkingCopier( @Nonnull protected Object getTargetRepository(@Nonnull final RepositoryInformation metadata) { - Class domainType = metadata.getDomainType(); + final Class domainType = metadata.getDomainType(); final EclipseStoreRepository existingRepository = this.storage.getRepository(domainType); if(existingRepository != null) @@ -129,7 +127,7 @@ protected Object getTargetRepository(@Nonnull final RepositoryInformation metada @Nonnull protected Class getRepositoryBaseClass(@Nonnull final RepositoryMetadata metadata) { - if(isLazyRepository(metadata)) + if(this.isLazyRepository(metadata)) { return LazySimpleEclipseStoreRepository.class; } diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/SimpleMultipleTest.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/SimpleMultipleTest.java index f9b68acc..7165730d 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/SimpleMultipleTest.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/SimpleMultipleTest.java @@ -19,14 +19,10 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import software.xdev.spring.data.eclipse.store.helper.TestData; import software.xdev.spring.data.eclipse.store.helper.TestUtil; import software.xdev.spring.data.eclipse.store.integration.TestConfiguration; -import software.xdev.spring.data.eclipse.store.integration.isolated.IsolatedTestAnnotations; -import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.lazy.SimpleLazyTestConfiguration; import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.Customer; import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.CustomerRepository; import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.Owner; diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/SimpleSingleTest.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/SimpleSingleTest.java index 5660ecb6..5ddf3ee9 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/SimpleSingleTest.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/SimpleSingleTest.java @@ -21,7 +21,6 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; import software.xdev.spring.data.eclipse.store.helper.TestData; import software.xdev.spring.data.eclipse.store.helper.TestUtil; @@ -81,6 +80,7 @@ void testBasicSaveAndFindSingleRecords() ); } + @SuppressWarnings("OptionalGetWithoutIsPresent") @Test void testBasicSaveAndFindMultipleRecords() { @@ -186,12 +186,12 @@ void testDoubleSaveAndFindAll() void testBasicSaveAndFindAllWithNotCrudRepository() { final CustomerNotCrud customer = new CustomerNotCrud(TestData.FIRST_NAME, TestData.LAST_NAME); - notCrudRepository.save(customer); + this.notCrudRepository.save(customer); TestUtil.doBeforeAndAfterRestartOfDatastore( this.configuration, () -> { - final List customers = TestUtil.iterableToList(notCrudRepository.findAll()); + final List customers = TestUtil.iterableToList(this.notCrudRepository.findAll()); Assertions.assertEquals(1, customers.size()); Assertions.assertEquals(customer, customers.get(0)); } diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/CustomerAsRecordLazyRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/CustomerAsRecordLazyRepository.java index 87389d17..74cc9869 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/CustomerAsRecordLazyRepository.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/CustomerAsRecordLazyRepository.java @@ -15,8 +15,6 @@ */ package software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.lazy; -import java.util.Optional; - import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.CustomerAsRecord; import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.CustomerAsRecordRepository; import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreCrudRepository; @@ -26,3 +24,4 @@ public interface CustomerAsRecordLazyRepository extends LazyEclipseStoreCrudRepository, CustomerAsRecordRepository { } + diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/CustomerLazyRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/CustomerLazyRepository.java index ecd5b152..1e4f230e 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/CustomerLazyRepository.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/CustomerLazyRepository.java @@ -15,11 +15,6 @@ */ package software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.lazy; -import java.util.Optional; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; - import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.Customer; import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.CustomerRepository; import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreCrudRepository; diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/model/CustomerRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/model/CustomerRepository.java index b5e0c48f..23796129 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/model/CustomerRepository.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/model/CustomerRepository.java @@ -15,12 +15,10 @@ */ package software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model; -import java.util.List; import java.util.Optional; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.PagingAndSortingRepository; diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/CustomerAsRecordNonLazyRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/CustomerAsRecordNonLazyRepository.java index 0fc770c7..df4ffff6 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/CustomerAsRecordNonLazyRepository.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/CustomerAsRecordNonLazyRepository.java @@ -18,7 +18,6 @@ import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.CustomerAsRecord; import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.CustomerAsRecordRepository; import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreCrudRepository; -import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreCrudRepository; public interface CustomerAsRecordNonLazyRepository diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/CustomerNonLazyRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/CustomerNonLazyRepository.java index 44931f04..ebb344b5 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/CustomerNonLazyRepository.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/CustomerNonLazyRepository.java @@ -19,8 +19,6 @@ import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.CustomerRepository; import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreCrudRepository; import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStorePagingAndSortingRepository; -import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreCrudRepository; -import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStorePagingAndSortingRepository; public interface CustomerNonLazyRepository diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/CustomerNotCrudNonLazyRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/CustomerNotCrudNonLazyRepository.java index c98fb18d..cded5984 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/CustomerNotCrudNonLazyRepository.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/CustomerNotCrudNonLazyRepository.java @@ -18,11 +18,9 @@ import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.CustomerNotCrud; import software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.model.CustomerNotCrudRepository; import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository; -import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreRepository; public interface CustomerNotCrudNonLazyRepository extends EclipseStoreRepository, CustomerNotCrudRepository { } - From 911c2faa67b1e5b789d65c4d68c85abf0d89fda9 Mon Sep 17 00:00:00 2001 From: JohannesRabauer Date: Mon, 9 Dec 2024 16:36:01 +0100 Subject: [PATCH 54/54] Stopped executing pmd cpd check because it is not working to exclude classes --- .github/workflows/check-build.yml | 3 --- .../data/eclipse/store/demo/lazy/LazyDemoApplication.java | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/check-build.yml b/.github/workflows/check-build.yml index 8278056f..33f70104 100644 --- a/.github/workflows/check-build.yml +++ b/.github/workflows/check-build.yml @@ -117,9 +117,6 @@ jobs: - name: Run PMD run: ./mvnw -B test pmd:aggregate-pmd-no-fork pmd:check -P pmd -DskipTests -T2C - - name: Run CPD (Copy Paste Detector) - run: ./mvnw -B pmd:aggregate-cpd pmd:cpd-check -P pmd -DskipTests -T2C - - name: Upload report if: always() uses: actions/upload-artifact@v4 diff --git a/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/LazyDemoApplication.java b/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/LazyDemoApplication.java index 6502081e..7fcd5ec8 100644 --- a/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/LazyDemoApplication.java +++ b/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/LazyDemoApplication.java @@ -21,7 +21,7 @@ import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; - + @SpringBootApplication public class LazyDemoApplication implements CommandLineRunner