From 89765c3a1fc0a0193223c92f548b396596e39f18 Mon Sep 17 00:00:00 2001 From: Ihar Hancharenka Date: Sat, 28 Sep 2024 22:04:50 +0300 Subject: [PATCH] m --- .../spring/data/jpa/docs/presentations.txt | 13 +++++++++++-- pl/java/libfws/spring/data/jpa/docs/tips.txt | 12 ++++++++---- .../spring/data/jpa/features/metamodel.txt | 16 ++++++++++++++++ .../data/jpa/features/transaction-locks.txt | 9 +++++++++ .../spring/data/jpa/tools/mihalcea-flexypool.txt | 2 ++ .../tools/sprig-boot-data-source-decorator.txt | 9 +++++++++ 6 files changed, 55 insertions(+), 6 deletions(-) create mode 100644 pl/java/libfws/spring/data/jpa/features/metamodel.txt create mode 100644 pl/java/libfws/spring/data/jpa/tools/mihalcea-flexypool.txt create mode 100644 pl/java/libfws/spring/data/jpa/tools/sprig-boot-data-source-decorator.txt diff --git a/pl/java/libfws/spring/data/jpa/docs/presentations.txt b/pl/java/libfws/spring/data/jpa/docs/presentations.txt index 994835728..0e64104bd 100644 --- a/pl/java/libfws/spring/data/jpa/docs/presentations.txt +++ b/pl/java/libfws/spring/data/jpa/docs/presentations.txt @@ -49,6 +49,17 @@ JPoint - Ilya and Fedor Sazonov - DB Tamer of 48:02 ! https://www.youtube.com/watch?v=mIxr65ZGGFw ! hikari ! 43:00 pgBouncer ? +Devoxx - Performance oriented Spring Data JPA & Hibernate by Maciej Walkowiak 23:00 of 43:43 + !!! + https://www.youtube.com/watch?v=exqfB1WaqIw + ! DB connection pool (hikari) should not be too big (even 100 is big) + ! need to optimize queries + https://github.com/gavlyukovskiy/spring-boot-data-source-decorator + https://p6spy.readthedocs.io/en/latest/index.html + ! to post-pone connection obtaining till real DB-call + ! spring.datasource.hikari.auto-commit=false # spring will not open connection untill real DB access + ! if long ext-call is after DB-call - need to use spring transactionTemplate + ! Amplicode - Lombok Problems with Spring Data JPA 0:00 of 12:00 https://www.youtube.com/watch?v=7kdQTh4oOQM Build faster persistence layers with Spring Data JPA 3 by Thorben Janssen @ Spring I/O 2024 0:00 of 49:49 @@ -56,8 +67,6 @@ Build faster persistence layers with Spring Data JPA 3 by Thorben Janssen @ Spri https://2024.springio.net/slides/build-faster-persistence-layers-with-spring-data-jpa-3-springio24.pdf Telusko - Spring Data JPA 0:00 of 28:27 https://www.youtube.com/watch?v=ImBqsE2exGo -Devoxx - Performance oriented Spring Data JPA & Hibernate by Maciej Walkowiak 14:00 of 43:43 - https://www.youtube.com/watch?v=exqfB1WaqIw 2023 Spilka - JPA/Hibernate Fundamentals 2023 of 7 parts https://www.youtube.com/playlist?list=PLEocw3gLFc8UYNv0uRG399GSggi8icTL6 diff --git a/pl/java/libfws/spring/data/jpa/docs/tips.txt b/pl/java/libfws/spring/data/jpa/docs/tips.txt index 6073aae68..db85ff767 100644 --- a/pl/java/libfws/spring/data/jpa/docs/tips.txt +++ b/pl/java/libfws/spring/data/jpa/docs/tips.txt @@ -3,7 +3,11 @@ https://habr.com/ru/articles/265061/ 2024 https://habr.com/ru/articles/824936/ https://habr.com/ru/companies/magnit/articles/814573/ - ! criteria-api - @OneToMany - @Fetch(FetchMode.SUBSELECT) // but does now work with pagination, hbm-bug - @Formula-annotation + ! which to replace criteria-api by - QueryDSL + @DynamicUpdate - to not cache update p-stmt + ! for N+1 problem solving + @OneToMany @BatchSize(size=50) + @OneToMany @Fetch(FetchMode.SUBSELECT) // but does now work with pagination, hbm-bug + @Formula("price * quantity") + @Formula("SEQURE_RAND(quantity)") + @Formula("(select count(*) from FORMULA_TABLE f where f.price < price)") diff --git a/pl/java/libfws/spring/data/jpa/features/metamodel.txt b/pl/java/libfws/spring/data/jpa/features/metamodel.txt new file mode 100644 index 000000000..368933a10 --- /dev/null +++ b/pl/java/libfws/spring/data/jpa/features/metamodel.txt @@ -0,0 +1,16 @@ +https://projectlombok.org/features/experimental/FieldNameConstants + +https://habr.com/ru/companies/magnit/articles/814573/ + +ext { + jpamodelgenVersion = '6.4.4.Final' +} + +implementation "org.hibernate:hibernate-jpamodelgen:${jpamodelgenVersion}" +annotationProcessor "org.hibernate:hibernate-jpamodelgen:${jpamodelgenVersion}" + +sourceSets.main.java.srcDirs += layout.buildDirectory.dir("/generated") + +compileJava { + options.generatedSourceOutputDirectory = layout.buildDirectory.dir("/generated") +} diff --git a/pl/java/libfws/spring/data/jpa/features/transaction-locks.txt b/pl/java/libfws/spring/data/jpa/features/transaction-locks.txt index b18332e1c..88c229803 100644 --- a/pl/java/libfws/spring/data/jpa/features/transaction-locks.txt +++ b/pl/java/libfws/spring/data/jpa/features/transaction-locks.txt @@ -1,3 +1,7 @@ +https://docs.spring.io/spring-framework/reference/data-access/transaction/programmatic.html + TransactionTemplate + TransactionalOperator + https://docs.oracle.com/javaee/7/api/javax/persistence/LockModeType.html READ, OPTIMISTIC, (obtains an optimistic read lock for all entities containing a version attribute) persistence provider will prevent our data from dirty reads as well as non-repeatable reads. @@ -41,6 +45,8 @@ https://www.linkedin.com/pulse/implementing-optimistic-pessimistic-locking-sprin adv, disadv https://github.com/csdavidg/db-locking-poc 2022 +https://habr.com/ru/articles/682362/ + https://www.marcobehler.com/guides/spring-transaction-management-transactional-in-depth https://vladmihalcea.com/spring-transaction-best-practices/ https://vladmihalcea.com/read-write-read-only-transaction-routing-spring/ https://vladmihalcea.com/spring-data-jpa-locking/ @@ -117,5 +123,8 @@ https://hackernoon.com/optimistic-and-pessimistic-locking-in-jpa 2021 https://habr.com/ru/company/otus/blog/574470/ spring transactional errors +2020 +https://habr.com/ru/articles/532000/ + !!! like a ref-ce 2017 https://habr.com/ru/articles/325470/ diff --git a/pl/java/libfws/spring/data/jpa/tools/mihalcea-flexypool.txt b/pl/java/libfws/spring/data/jpa/tools/mihalcea-flexypool.txt new file mode 100644 index 000000000..c701d0bde --- /dev/null +++ b/pl/java/libfws/spring/data/jpa/tools/mihalcea-flexypool.txt @@ -0,0 +1,2 @@ +https://github.com/vladmihalcea/flexy-pool +implementation 'com.vladmihalcea.flexy-pool:flexy-pool-parent:2.2.3' diff --git a/pl/java/libfws/spring/data/jpa/tools/sprig-boot-data-source-decorator.txt b/pl/java/libfws/spring/data/jpa/tools/sprig-boot-data-source-decorator.txt new file mode 100644 index 000000000..1a5ce5707 --- /dev/null +++ b/pl/java/libfws/spring/data/jpa/tools/sprig-boot-data-source-decorator.txt @@ -0,0 +1,9 @@ +https://github.com/gavlyukovskiy/spring-boot-data-source-decorator + +decorator.datasource.datasource-proxy.slow-query.enable-logging=true +decorator.datasource.datasource-proxy.slow-query.log-level=warn +decorator.datasource.datasource-proxy.slow-query.logger-name= +# Number of seconds to consider query as slow and log it +decorator.datasource.datasource-proxy.slow-query.threshold=300 + +decorator.datasource.datasource-proxy.multiline=true