From 75f305427021b9635381003cd983b66f8cec03f9 Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Wed, 4 Oct 2023 19:41:49 +0530 Subject: [PATCH] feat: adds mapstruct to compiler plugin --- .../README.md | 70 +- .../pom.xml | 799 +++++++++--------- 2 files changed, 457 insertions(+), 412 deletions(-) diff --git a/jpa/boot-hibernate2ndlevelcache-sample/README.md b/jpa/boot-hibernate2ndlevelcache-sample/README.md index 7eb181062..876eabd69 100644 --- a/jpa/boot-hibernate2ndlevelcache-sample/README.md +++ b/jpa/boot-hibernate2ndlevelcache-sample/README.md @@ -1,29 +1,41 @@ -# boot-hibernate2ndlevelcache-sample - -The Hibernate second level cache is a cache that is used to store the data that has been retrieved from the database. This cache is used to improve the performance of the application by reducing the number of trips to the database and providing quick access to frequently used data. The second level cache is typically implemented at the session factory level and is shared across all sessions within the factory. It is also configurable and can be enabled or disabled as needed. It is separate from the first level cache, which is associated with a session and only stores objects for the duration of that session. The second level cache is shared across sessions and can be configured to use various cache providers, such as Ehcache or Infinispan. - -### Run tests - -```shell -./mvnw clean verify -``` - -### Run locally - -```shell -docker-compose -f docker/docker-compose.yml up -d -./mvnw spring-boot:run -Dspring-boot.run.profiles=local -``` - -### Useful Links - -* Swagger UI: http://localhost:8080/swagger-ui.html -* Actuator Endpoint: http://localhost:8080/actuator -* Prometheus: http://localhost:9090/ -* Grafana: http://localhost:3000/ (admin/admin) -* Kibana: http://localhost:5601/ - -### Notes - -* We need to explicitly set the querycacheHint to customerqueries for enabling 2nd level cache -* This is enabled only for SessionFactory(i.e as soon as application is closed it will be deleted) +# boot-hibernate2ndlevelcache-sample + +The Hibernate second level cache is a cache that is used to store the data that has been retrieved from the database. This cache is used to improve the performance of the application by reducing the number of trips to the database and providing quick access to frequently used data. The second level cache is typically implemented at the session factory level and is shared across all sessions within the factory. It is also configurable and can be enabled or disabled as needed. It is separate from the first level cache, which is associated with a session and only stores objects for the duration of that session. The second level cache is shared across sessions and can be configured to use various cache providers, such as Ehcache or Infinispan. + +### Run tests + +```shell +./mvnw clean verify +``` + +### Run locally + +```shell +docker-compose -f docker/docker-compose.yml up -d +./mvnw spring-boot:run -Dspring-boot.run.profiles=local +``` + +### Useful Links + +* Swagger UI: http://localhost:8080/swagger-ui.html +* Actuator Endpoint: http://localhost:8080/actuator +* Prometheus: http://localhost:9090/ +* Grafana: http://localhost:3000/ (admin/admin) +* Kibana: http://localhost:5601/ + +### Notes + +* We need to explicitly set the querycacheHint to customerqueries for enabling 2nd level cache +* This is enabled only for SessionFactory(i.e as soon as application is closed it will be deleted) + +### **Caching Collections (One-Many & Many-Many Relations)** + + +Collection caching allows you to cache entire collections of associated entities. These collections can be part of your domain model, such as one-to-many or many-to-many relationships between entities. + +Collection caching is valuable when dealing with associations between entities that are frequently loaded and where caching can lead to significant performance gains. When you enable collection caching, Hibernate caches entire collections, such as lists or sets, associated with an entity. + +When Hibernate caches a collection, it doesn’t cache the entire collection of entities but rather caches the IDs of the entities contained in the collection. + +* Caching only the IDs reduces memory usage compared to caching the entire collection of entities. +* When a collection is updated, only the relevant IDs need to be invalidated in the cache, rather than the entire collection. This minimizes cache invalidation overhead. diff --git a/jpa/boot-hibernate2ndlevelcache-sample/pom.xml b/jpa/boot-hibernate2ndlevelcache-sample/pom.xml index 4976569e1..50a084f78 100644 --- a/jpa/boot-hibernate2ndlevelcache-sample/pom.xml +++ b/jpa/boot-hibernate2ndlevelcache-sample/pom.xml @@ -1,383 +1,416 @@ - - - 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 3.1.4 - - - com.example.hibernatecache - boot-hibernate2ndlevelcache-sample - 0.0.1-SNAPSHOT - boot-hibernate2ndlevelcache-sample - hibernate 2ndlevel cache Implementation - - - UTF-8 - UTF-8 - - 17 - - 2.2.0 - 2.14.0 - - ${project.build.directory}/test-results - 2.40.0 - 8.4.0 - 1.2.0 - 3.10.0.2594 - 0.8.10 - 0.80 - ${project.build.directory}/jacoco/test - ${jacoco.utReportFolder}/test.exec - ${project.build.directory}/jacoco/integrationTest - ${jacoco.itReportFolder}/integrationTest.exec - ${project.testresult.directory}/test - ${project.testresult.directory}/integrationTest - - - - - org.springframework.boot - spring-boot-starter-actuator - - - org.springframework.boot - spring-boot-starter-cache - - - org.springframework.boot - spring-boot-starter-validation - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-devtools - runtime - true - - - org.springframework.boot - spring-boot-configuration-processor - true - - - org.projectlombok - lombok - true - - - org.springframework.boot - spring-boot-starter-data-jpa - - - org.springframework.boot - spring-boot-starter-data-redis - - - com.h2database - h2 - runtime - - - org.postgresql - postgresql - runtime - - - org.liquibase - liquibase-core - - - org.redisson - redisson-hibernate-6 - 3.23.5 - - - io.hypersistence - hypersistence-utils-hibernate-62 - 3.5.3 - - - net.ttddyy - datasource-proxy - 1.9 - - - - org.springdoc - springdoc-openapi-starter-webmvc-ui - ${springdoc-openapi.version} - - - org.apache.commons - commons-lang3 - - - commons-io - commons-io - ${commons-io.version} - - - - org.springframework.boot - spring-boot-starter-test - test - - - org.awaitility - awaitility - test - - - org.testcontainers - junit-jupiter - test - - - org.testcontainers - postgresql - test - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - build-info - - - - - - io.github.git-commit-id - git-commit-id-maven-plugin - - - - revision - - - - - false - false - true - - ^git.branch$ - ^git.commit.id.abbrev$ - ^git.commit.user.name$ - ^git.commit.message.full$ - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - alphabetical - ${junit.utReportFolder} - - **/*IT* - **/*IntTest* - **/*IntegrationTest* - - - - - org.apache.maven.plugins - maven-failsafe-plugin - ${maven-failsafe-plugin.version} - - ${project.build.outputDirectory} - alphabetical - ${junit.itReportFolder} - - **/*IT* - **/*IntTest* - **/*IntegrationTest* - - - - - integration-test - - integration-test - - - - verify - - verify - - - - - - org.codehaus.mojo - properties-maven-plugin - ${properties-maven-plugin.version} - - - initialize - - read-project-properties - - - - sonar-project.properties - - - - - - - com.diffplug.spotless - spotless-maven-plugin - ${spotless.version} - - - - 1.17.0 - - - - - - - compile - - check - - - - - - org.jacoco - jacoco-maven-plugin - ${jacoco-maven-plugin.version} - - ${project.build.directory}/jacoco/test/jacoco.exec - - - BUNDLE - - - COMPLEXITY - COVEREDRATIO - ${jacoco.minimum.coverage} - - - - - - **/*Application.* - **/config/** - **/models/* - **/dtos/* - **/exceptions/* - **/*Constants* - - - - - pre-unit-tests - - prepare-agent - - - - ${jacoco.utReportFile} - - - - - post-unit-test - test - - report - - - ${jacoco.utReportFile} - ${jacoco.utReportFolder} - - - - pre-integration-tests - - prepare-agent-integration - - - - ${jacoco.itReportFile} - - - - - post-integration-tests - post-integration-test - - report-integration - - - ${jacoco.itReportFile} - ${jacoco.itReportFolder} - - - - - - org.owasp - dependency-check-maven - ${dependency-check-maven.version} - - false - - - - org.sonarsource.scanner.maven - sonar-maven-plugin - ${sonar-maven-plugin.version} - - - - sonar - - - - - - - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.1.4 + + + com.example.hibernatecache + boot-hibernate2ndlevelcache-sample + 0.0.1-SNAPSHOT + boot-hibernate2ndlevelcache-sample + hibernate 2ndlevel cache Implementation + + + UTF-8 + UTF-8 + + 17 + + 2.2.0 + 2.14.0 + 1.5.5.Final + + ${project.build.directory}/test-results + 2.40.0 + 8.4.0 + 1.2.0 + 3.10.0.2594 + 0.8.10 + 0.80 + ${project.build.directory}/jacoco/test + ${jacoco.utReportFolder}/test.exec + ${project.build.directory}/jacoco/integrationTest + ${jacoco.itReportFolder}/integrationTest.exec + ${project.testresult.directory}/test + ${project.testresult.directory}/integrationTest + + + + + org.springframework.boot + spring-boot-starter-actuator + + + org.springframework.boot + spring-boot-starter-cache + + + org.springframework.boot + spring-boot-starter-validation + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-devtools + runtime + true + + + org.springframework.boot + spring-boot-configuration-processor + true + + + org.projectlombok + lombok + true + + + org.mapstruct + mapstruct + ${org.mapstruct.version} + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.springframework.boot + spring-boot-starter-data-redis + + + com.h2database + h2 + runtime + + + org.postgresql + postgresql + runtime + + + org.liquibase + liquibase-core + + + org.redisson + redisson-hibernate-6 + 3.23.5 + + + io.hypersistence + hypersistence-utils-hibernate-62 + 3.5.3 + + + net.ttddyy + datasource-proxy + 1.9 + + + + org.springdoc + springdoc-openapi-starter-webmvc-ui + ${springdoc-openapi.version} + + + org.apache.commons + commons-lang3 + + + commons-io + commons-io + ${commons-io.version} + + + + org.springframework.boot + spring-boot-starter-test + test + + + org.awaitility + awaitility + test + + + org.testcontainers + junit-jupiter + test + + + org.testcontainers + postgresql + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + build-info + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + ${java.version} + ${java.version} + + + org.mapstruct + mapstruct-processor + ${org.mapstruct.version} + + + + org.projectlombok + lombok + ${lombok.version} + + + + org.projectlombok + lombok-mapstruct-binding + 0.2.0 + + + + + + io.github.git-commit-id + git-commit-id-maven-plugin + + + + revision + + + + + false + false + true + + ^git.branch$ + ^git.commit.id.abbrev$ + ^git.commit.user.name$ + ^git.commit.message.full$ + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + alphabetical + ${junit.utReportFolder} + + **/*IT* + **/*IntTest* + **/*IntegrationTest* + + + + + org.apache.maven.plugins + maven-failsafe-plugin + ${maven-failsafe-plugin.version} + + ${project.build.outputDirectory} + alphabetical + ${junit.itReportFolder} + + **/*IT* + **/*IntTest* + **/*IntegrationTest* + + + + + integration-test + + integration-test + + + + verify + + verify + + + + + + org.codehaus.mojo + properties-maven-plugin + ${properties-maven-plugin.version} + + + initialize + + read-project-properties + + + + sonar-project.properties + + + + + + + com.diffplug.spotless + spotless-maven-plugin + ${spotless.version} + + + + 1.17.0 + + + + + + + compile + + check + + + + + + org.jacoco + jacoco-maven-plugin + ${jacoco-maven-plugin.version} + + ${project.build.directory}/jacoco/test/jacoco.exec + + + BUNDLE + + + COMPLEXITY + COVEREDRATIO + ${jacoco.minimum.coverage} + + + + + + **/*Application.* + **/config/** + **/models/* + **/dtos/* + **/exceptions/* + **/*Constants* + + + + + pre-unit-tests + + prepare-agent + + + + ${jacoco.utReportFile} + + + + + post-unit-test + test + + report + + + ${jacoco.utReportFile} + ${jacoco.utReportFolder} + + + + pre-integration-tests + + prepare-agent-integration + + + + ${jacoco.itReportFile} + + + + + post-integration-tests + post-integration-test + + report-integration + + + ${jacoco.itReportFile} + ${jacoco.itReportFolder} + + + + + + org.owasp + dependency-check-maven + ${dependency-check-maven.version} + + false + + + + org.sonarsource.scanner.maven + sonar-maven-plugin + ${sonar-maven-plugin.version} + + + + sonar + + + + + + + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + false + + + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + false + + + +