{"id":348447,"date":"2023-06-07T15:04:09","date_gmt":"2023-06-07T15:04:09","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=348447"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=348447","title":{"rendered":"<span>Spring Data JPA: \u0437\u0430\u043c\u0435\u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043e\u0434\u043d\u0438\u043c \u0438 \u043f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u043e<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043a\u043e\u0441\u043d\u0443\u0441\u044c \u0442\u0435\u043c\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043a\u0430\u043a \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u043a\u043e\u0434\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0442 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0437\u0430 \u0441\u0447\u0435\u0442 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439.<\/p>\n<p>\u0418 \u0442\u0430\u043a \u043f\u043e\u0435\u0445\u0430\u043b\u0438.<\/p>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0442\u0430\u043a\u043e\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u0435: \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043a\u0430\u043a\u0430\u044f-\u0442\u043e \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0430\u043c\u0438, \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0430\u043a\u043a\u0430\u0443\u0442\u0435 \u0435\u0441\u0442\u044c \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u0430\u044f \u043f\u043e\u0447\u0442\u0430. \u041a \u043d\u0430\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u0441 \u043e\u0442\u0434\u0435\u043b\u0430 \u043c\u0430\u0440\u043a\u0435\u0442\u0438\u043d\u0433\u0430 \u0438 \u0433\u043e\u0432\u043e\u0440\u044f\u0442 &#171;\u0412\u043e\u0442 \u0432\u0430\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u0447\u0442\u043e\u0432\u044b\u0445 \u0430\u0434\u0440\u0435\u0441\u043e\u0432, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u0439\u0442\u0438\u0441\u044c \u043f\u043e \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0430\u043a\u043a\u0430\u0443\u0442\u0430\u043c\u0438, \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0435\u0441\u0442\u044c \u043b\u0438 \u0442\u0430\u043a\u0438\u0435 \u0430\u0434\u0440\u0435\u0441\u0430, \u0438 \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c &#8212; \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043d\u0430 \u044d\u0442\u0443 \u043f\u043e\u0447\u0442\u0443 \u043f\u0438\u0441\u044c\u043c\u043e&#187;.<\/p>\n<p>\u0412\u0440\u043e\u0434\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u043d\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0435, \u043d\u043e \u0435\u0441\u043b\u0438 \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0430\u043a\u043a\u0430\u0443\u0442\u043e\u0432 \u043d\u0435 \u0441\u043e\u0442\u043d\u0438, \u0430 \u0442\u044b\u0441\u044f\u0447\u0438 \u0438\u043b\u0438 \u0434\u0435\u0441\u044f\u0442\u043a\u0438 \u0442\u044b\u0441\u044f\u0447, \u0442\u043e \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043d\u0438\u0437\u0438\u0442\u044c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0448\u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u043f\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439.<\/p>\n<p>\u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0417\u0430\u0439\u0434\u0435\u043c \u043d\u0430 <a href=\"https:\/\/start.spring.io\/\" rel=\"noopener noreferrer nofollow\">https:\/\/start.spring.io\/<\/a> \u0438 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0440\u043e\u0435\u043a\u0442.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/88d\/417\/f44\/88d417f44d7bc7eb5a006721f263522c.png\" width=\"1714\" height=\"999\"><\/figure>\n<p>\u041e\u0442\u043a\u0440\u043e\u0435\u043c \u0435\u0433\u043e \u0432 \u0441\u0440\u0435\u0434\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c pom.xml<\/p>\n<pre><code class=\"java\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt; &lt;project xmlns=\"http:\/\/maven.apache.org\/POM\/4.0.0\" xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi:schemaLocation=\"http:\/\/maven.apache.org\/POM\/4.0.0 https:\/\/maven.apache.org\/xsd\/maven-4.0.0.xsd\"&gt; &lt;modelVersion&gt;4.0.0&lt;\/modelVersion&gt; &lt;parent&gt; &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt; &lt;artifactId&gt;spring-boot-starter-parent&lt;\/artifactId&gt; &lt;version&gt;3.1.0&lt;\/version&gt; &lt;relativePath\/&gt; &lt;!-- lookup parent from repository --&gt; &lt;\/parent&gt; &lt;groupId&gt;com.example&lt;\/groupId&gt; &lt;artifactId&gt;spring-data-jpa-multiple-single-queries&lt;\/artifactId&gt; &lt;version&gt;0.0.1-SNAPSHOT&lt;\/version&gt; &lt;name&gt;spring-data-jpa-multiple-single-queries&lt;\/name&gt; &lt;description&gt;Demo project for Spring Boot&lt;\/description&gt; &lt;properties&gt; &lt;java.version&gt;17&lt;\/java.version&gt; &lt;\/properties&gt; &lt;dependencies&gt; &lt;!--JPA--&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt; &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;\/artifactId&gt; &lt;\/dependency&gt; &lt;!--WEB--&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt; &lt;artifactId&gt;spring-boot-starter-web&lt;\/artifactId&gt; &lt;\/dependency&gt; &lt;!--DATABASE--&gt; &lt;dependency&gt; &lt;groupId&gt;org.postgresql&lt;\/groupId&gt; &lt;artifactId&gt;postgresql&lt;\/artifactId&gt; &lt;scope&gt;runtime&lt;\/scope&gt; &lt;\/dependency&gt; &lt;!--LIQUIBASE--&gt; &lt;dependency&gt; &lt;groupId&gt;org.liquibase&lt;\/groupId&gt; &lt;artifactId&gt;liquibase-core&lt;\/artifactId&gt; &lt;\/dependency&gt; &lt;!--LOMBOK--&gt; &lt;dependency&gt; &lt;groupId&gt;org.projectlombok&lt;\/groupId&gt; &lt;artifactId&gt;lombok&lt;\/artifactId&gt; &lt;optional&gt;true&lt;\/optional&gt; &lt;\/dependency&gt; &lt;!--TESTING--&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt; &lt;artifactId&gt;spring-boot-starter-test&lt;\/artifactId&gt; &lt;scope&gt;test&lt;\/scope&gt; &lt;\/dependency&gt; &lt;!--OTHERS--&gt; &lt;dependency&gt; &lt;groupId&gt;com.github.javafaker&lt;\/groupId&gt; &lt;artifactId&gt;javafaker&lt;\/artifactId&gt; &lt;version&gt;1.0.2&lt;\/version&gt; &lt;\/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.apache.commons&lt;\/groupId&gt; &lt;artifactId&gt;commons-lang3&lt;\/artifactId&gt; &lt;version&gt;3.9&lt;\/version&gt; &lt;\/dependency&gt; &lt;\/dependencies&gt;  &lt;build&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt; &lt;artifactId&gt;spring-boot-maven-plugin&lt;\/artifactId&gt; &lt;configuration&gt; &lt;excludes&gt; &lt;exclude&gt; &lt;groupId&gt;org.projectlombok&lt;\/groupId&gt; &lt;artifactId&gt;lombok&lt;\/artifactId&gt; &lt;\/exclude&gt; &lt;\/excludes&gt; &lt;\/configuration&gt; &lt;\/plugin&gt; &lt;\/plugins&gt; &lt;\/build&gt;  &lt;\/project&gt; <\/code><\/pre>\n<p>\u0411\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c postgresql, \u0434\u043b\u044f \u043d\u0430\u043a\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 \u043d\u0435\u0439 &#8212; liquibase.<\/p>\n<p>\u0411\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0434\u043d\u0438\u043c\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e docker-\u0430, \u0442\u0430\u043a\u0436\u0435 \u0432 \u0434\u043e\u043a\u0435\u0440\u0435 \u043f\u043e\u0434\u043d\u0438\u043c\u0435\u043c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0441 pgadmin &#8212; \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0431\u0430\u0437\u0435.<\/p>\n<p>\u0421\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043a\u043e\u0434 \u0441 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438.<\/p>\n<p>\u0412 \u043a\u043e\u0440\u043d\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043d\u0430\u043f\u0438\u0448\u0435\u043c docker-compose.yml \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435\u043c:<\/p>\n<pre><code class=\"java\">services:   service-db:     image: postgres:14.7-alpine     environment:       POSTGRES_USER: username       POSTGRES_PASSWORD: password     ports:       - \"15432:5432\"     volumes:       - .\/infrastructure\/db\/create_db.sql:\/docker-entrypoint-initdb.d\/create_db.sql       - db-data:\/var\/lib\/postgresql\/data     restart: unless-stopped    pgadmin:     container_name: pgadmin4_container     image: dpage\/pgadmin4:7     restart: always     environment:       PGADMIN_DEFAULT_EMAIL: admin@admin.com       PGADMIN_DEFAULT_PASSWORD: root     ports:       - \"5050:80\"     volumes:       - pgadmin-data:\/var\/lib\/pgadmin  volumes:   db-data:   pgadmin-data:<\/code><\/pre>\n<p>\u0411\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 accounts_database \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043a\u0440\u0438\u043f\u0442\u0430, \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u0432 \u043f\u0430\u043f\u043a\u0435 infrastructure\/db<\/p>\n<pre><code class=\"java\">create database accounts_database;<\/code><\/pre>\n<p>\u041e\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0441\u044f \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0432 docker-\u0435. \u0422\u0430\u043a\u0436\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u043d\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0441 \u043d\u0430\u0448\u0435\u0439 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u043e\u043d\u0438 \u043d\u0435 \u043f\u043e\u0442\u0435\u0440\u044f\u043b\u0438\u0441\u044c.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u0430\u0448\u0443 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c, \u0442\u043e \u0435\u0441\u0442\u044c \u0430\u043a\u043a\u0430\u0443\u043d\u0442.<\/p>\n<pre><code class=\"java\">@Data @Builder @Entity @NoArgsConstructor @AllArgsConstructor @Table(name = \"accounts\") public class Account {     @Id     @Column(name = \"id\")     @GeneratedValue(strategy = GenerationType.IDENTITY)     private Long id;     @Column(name=\"username\",             nullable = false)     private String username;     @Column(name=\"email\",             nullable = false)     private String email;     @Column(name=\"created_at\",             nullable = false)     private LocalDate createdAt;      public Account(String username, String email, LocalDate createdAt) {         this.username = username;         this.email = email;         this.createdAt = createdAt;     } }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043f\u0430\u043f\u043e\u043a \u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0430\u0439\u043b\u044b \u0434\u043b\u044f \u043d\u0430\u043a\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/373\/39b\/606\/37339b606f76b618c9f839681eebda64.png\" width=\"386\" height=\"146\"><\/figure>\n<p>2023-06-06-1-create-table-accounts.xml<\/p>\n<pre><code class=\"java\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\" ?&gt; &lt;databaseChangeLog         xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"         xmlns=\"http:\/\/www.liquibase.org\/xml\/ns\/dbchangelog\"         xsi:schemaLocation=\"http:\/\/www.liquibase.org\/xml\/ns\/dbchangelog http:\/\/www.liquibase.org\/xml\/ns\/dbchangelog\/dbchangelog-3.1.xsd\"&gt;      &lt;changeSet logicalFilePath=\"2023-06-06-1-create-table-accounts\"                id=\"2023-06-06-1-create-table-accounts\" author=\"s.m\"&gt;         &lt;createTable tableName=\"accounts\"&gt;             &lt;column name=\"id\" type=\"serial\"&gt;                 &lt;constraints nullable=\"false\" primaryKey=\"true\"\/&gt;             &lt;\/column&gt;             &lt;column name=\"username\" type=\"varchar(255)\"&gt;                 &lt;constraints nullable=\"false\"\/&gt;             &lt;\/column&gt;             &lt;column name=\"email\" type=\"varchar(255)\"&gt;                 &lt;constraints nullable=\"false\"\/&gt;             &lt;\/column&gt;             &lt;column name=\"created_at\" type=\"date\"&gt;                 &lt;constraints nullable=\"false\"\/&gt;             &lt;\/column&gt;         &lt;\/createTable&gt;     &lt;\/changeSet&gt; &lt;\/databaseChangeLog&gt;<\/code><\/pre>\n<p>cumulative.xml<\/p>\n<pre><code class=\"java\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\" ?&gt; &lt;databaseChangeLog         xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"         xmlns=\"http:\/\/www.liquibase.org\/xml\/ns\/dbchangelog\"         xsi:schemaLocation=\"http:\/\/www.liquibase.org\/xml\/ns\/dbchangelog http:\/\/www.liquibase.org\/xml\/ns\/dbchangelog\/dbchangelog-3.1.xsd\"&gt;      &lt;include file=\"2023-06-06-1-create-table-accounts.xml\" relativeToChangelogFile=\"true\" \/&gt; &lt;\/databaseChangeLog&gt;<\/code><\/pre>\n<p>db.changelog-master.xml<\/p>\n<pre><code class=\"java\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\" ?&gt; &lt;databaseChangeLog         xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"         xmlns=\"http:\/\/www.liquibase.org\/xml\/ns\/dbchangelog\"         xsi:schemaLocation=\"http:\/\/www.liquibase.org\/xml\/ns\/dbchangelog http:\/\/www.liquibase.org\/xml\/ns\/dbchangelog\/dbchangelog-3.1.xsd\"&gt;      &lt;include file=\"v.1.0.0\/cumulative.xml\" relativeToChangelogFile=\"true\" \/&gt;  &lt;\/databaseChangeLog&gt;<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 AccountRepository \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0441 \u043d\u0430\u0448\u0435\u0439 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c\u044e \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<pre><code class=\"java\">@Repository public interface AccountRepository extends JpaRepository&lt;Account, Long&gt; { }<\/code><\/pre>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0448\u0430\u0433\u043e\u043c \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0430\u0439\u043b application.yml<\/p>\n<pre><code class=\"java\">server:   port: 8081 spring:   datasource:     url: jdbc:postgresql:\/\/${DB_HOST:localhost}:${DB_PORT:15432}\/accounts_database     username: username     password: password   liquibase:     enabled: true     drop-first: false     change-log: classpath:db\/changelog\/db.changelog-master.xml     default-schema: public   jpa:     show-sql: true     properties:       hibernate:         format_sql: true<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u043d\u0430\u0448\u0435\u0439 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c liquibase \u0438 \u0437\u0430\u0434\u0430\u0435\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438, \u0447\u0442\u043e\u0431\u044b \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0432\u044b\u0432\u043e\u0434\u0438\u043b\u0438\u0441\u044c sql \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043a\u0430\u043a\u0438\u043c\u0438-\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u0441 \u043d\u0438\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c.<\/p>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438 \u0432 \u043d\u0430\u0448\u0435\u0439 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 10 000 \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u043e\u0432, \u0430 \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0435\u0441\u0442\u044c \u043b\u0438 \u0442\u0430\u043a\u0438\u0435 email-\u044b \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c 5 000 \u0430\u0434\u0440\u0435\u0441\u043e\u0432 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0439 \u043f\u043e\u0447\u0442\u044b.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043b\u0430\u0441\u0441 ConstantData \u0432 \u043f\u0430\u043f\u043a\u0435 config.<\/p>\n<pre><code class=\"java\">public class ConstantData {      public final static int NUMBER_ACCOUNTS = 10_000;     public final static int NUMBER_OF_EMAILS_TO_SEND = (NUMBER_ACCOUNTS \/ 2) + 1;     public final static List&lt;String&gt; LIST_OF_EMAILS_TO_SEND = createListOfEmails();      static List&lt;String&gt; createListOfEmails() {         Faker faker = new Faker();         List&lt;String&gt; emailsToSend = new ArrayList&lt;&gt;();         for (int i = 0; i &lt; NUMBER_OF_EMAILS_TO_SEND; i++) {             emailsToSend.add(faker.internet().emailAddress());         }         return emailsToSend;     } }<\/code><\/pre>\n<p>\u0412 \u043c\u0435\u0442\u043e\u0434\u0435 createListOfEmails() \u043c\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 javafaker \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c 5000 \u0430\u0434\u0440\u0435\u0441\u043e\u0432 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0439 \u043f\u043e\u0447\u0442\u044b.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u043a\u043b\u0430\u0441\u0441 DataLoader.<\/p>\n<pre><code class=\"java\">@Component public class DataLoader {      @Bean     public CommandLineRunner loadDataAccount(AccountRepository accountRepository) {         return (args) -&gt; {             Faker faker = new Faker();             for (int i = 1; i &lt;= ConstantData.NUMBER_ACCOUNTS; i++) {                 String username = faker.name().username();                 String email = \"\";                 if (i % 2 == 0) {                     email = ConstantData.LIST_OF_EMAILS_TO_SEND.get(i \/ 2);                 } else {                     email = faker.internet().emailAddress();                 }                 Account account = Account.builder()                         .username(username)                         .email(email)                         .createdAt(LocalDate.of(2022, Month.JANUARY, 1).plusDays(faker.number().numberBetween(1, 365)))                         .build();                 accountRepository.save(account);             }         };     } } <\/code><\/pre>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 loadDataAccount \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c 10 000 \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u043e\u0432 \u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0430 \u0430\u0434\u0440\u0435\u0441\u043e\u0432 \u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0432\u0437\u044f\u0442\u0430 \u0438\u0437 \u0440\u0430\u043d\u0435\u0435 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u0441 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u044b\u043c\u0438 \u0430\u0434\u0440\u0435\u0441\u0430\u043c\u0438.<\/p>\n<p>\u041f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0432\u0441\u0435 \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 AccountService \u0441 \u043c\u0435\u0442\u043e\u0434\u043e\u043c getEmailExistsInDBMultipleQueries(List targetEmailList).<\/p>\n<pre><code class=\"java\">public interface AccountService {      List&lt;String&gt; getEmailExistsInDBMultipleQueries(List&lt;String&gt; targetEmailList);  }<\/code><\/pre>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043b\u0438 \u0430\u0434\u0440\u0435\u0441 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0439 \u043f\u043e\u0447\u0442\u044b \u0432 \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0435, \u0442\u043e \u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435 AccountRepository \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043c\u0435\u0442\u043e\u0434 boolean existsByEmail(String email), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Spring Data JPA , \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u0434\u043b\u044f \u043d\u0430\u0441 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e &#171;\u0432\u043e\u043b\u0448\u0435\u0431\u043d\u044b\u0439&#187; \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0439\u0434\u0435\u0442 \u0432 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442 \u0435\u0441\u0442\u044c \u043b\u0438 \u0443 \u043a\u0430\u043a\u043e\u0433\u043e-\u0442\u043e \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0430 \u0442\u0430\u043a\u043e\u0439 \u0430\u0434\u0440\u0435\u0441 \u0438 \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c &#8212; \u0432\u0435\u0440\u043d\u0435\u0442 true.<\/p>\n<pre><code class=\"java\">boolean existsByEmail(String email);<\/code><\/pre>\n<p>\u0410 \u0442\u0430\u043a\u0436\u0435 \u043a\u043b\u0430\u0441\u0441 AccountServiceImpl, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0438\u0442\u044c \u043a\u043b\u0430\u0441\u0441 AccountService.<\/p>\n<pre><code class=\"java\">@Slf4j @Service @RequiredArgsConstructor @Transactional(readOnly = true) public class AccountServiceImpl implements AccountService{      private final AccountRepository accountRepository;      @Override     public List&lt;String&gt; getEmailExistsInDBMultipleQueries(List&lt;String&gt; targetEmailList) {         return  targetEmailList.stream()                 .filter(accountRepository::existsByEmail)                 .toList();     }  }<\/code><\/pre>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0435 \u043c\u044b \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c\u0441\u044f \u043f\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0441\u043f\u0438\u0441\u043a\u0443 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u044b\u0445 \u0430\u0434\u0440\u0435\u0441\u043e\u0432 \u0438 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0430\u0434\u0440\u0435\u0441\u0443 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043b\u0438 \u0442\u0430\u043a\u043e\u0439 \u0430\u043a\u043a\u0430\u0443\u043d\u0442 \u0441 \u0442\u0430\u043a\u0438\u043c \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u044b\u043c \u0430\u0434\u0440\u0435\u0441\u043e\u043c \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c &#8212; \u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u044d\u0442\u043e\u0442 \u0430\u0434\u0440\u0435\u0441 \u0441 \u0441\u043f\u0438\u0441\u043e\u043a.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0441\u0435\u0440\u0432\u0438\u0441 NotificationService, \u0433\u0434\u0435 \u0431\u0443\u0434\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 getEmailExistsInDBMultipleQueries \u0438 \u0437\u0430\u043c\u0435\u0440\u044f\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0435\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u043d\u0430 \u044d\u043a\u0440\u0430\u043d \u0440\u0430\u0437\u043c\u0435\u0440 \u0441\u043f\u0438\u0441\u043a\u0430 \u0441 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u044b\u043c\u0438 \u0430\u0434\u0440\u0435\u0441\u0430\u043c\u0438.<\/p>\n<pre><code class=\"java\">@Slf4j @Service @RequiredArgsConstructor @Transactional(readOnly = true) public class NotificationService {     private final AccountService accountService;      public void sendEmailMultipleQueries(){         List&lt;String&gt; targetEmailList = ConstantData.LIST_OF_EMAILS_TO_SEND;         StopWatch stopWatch = new StopWatch();         stopWatch.start();         List&lt;String&gt; listEmailToSend = accountService.getEmailExistsInDBMultipleQueries(targetEmailList);         \/\/email send code         stopWatch.stop();         System.out.println(\"Time has passed with to check if an account with this email exists with multiple queries, ms: \" + stopWatch.getTime());         System.out.println(\"Size of emails list: \" + listEmailToSend.size());     }  }<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043d\u0430\u043f\u0438\u0448\u0435\u043c &#8212; \u044d\u0442\u043e AccountController, \u0433\u0434\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0430\u0448 \u043c\u0435\u0442\u043e\u0434 \u0438 \u0435\u0433\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c.<\/p>\n<pre><code class=\"java\">@Slf4j @Validated @RestController @RequiredArgsConstructor @RequestMapping(\"\/api\/v1\/accounts\") public class AccountController {          private final NotificationService notificationService;      @GetMapping(\"\/emailSendMultipleQueries\")     @ResponseStatus(HttpStatus.OK)     public void emailSendMultipleQueries() {         log.info(\"Send emails with multiple queries\");         notificationService.sendEmailMultipleQueries();     }  }<\/code><\/pre>\n<p>\u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u043a \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u0434\u0430.<\/p>\n<p>\u0412\u043d\u0430\u0447\u0430\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 docker-compose up -d \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435, \u0433\u0434\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430\u0448 docker-compose.yml \u0444\u0430\u0439\u043b.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d9b\/099\/143\/d9b0991434ee251debfe2a56117fb02f.png\" width=\"1064\" height=\"236\"><\/figure>\n<p>\u041a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u0434\u043d\u044f\u0442\u044c\u0441\u044f \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c.<\/p>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0437\u0430\u0439\u043c\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f, \u0442\u0430\u043a \u043a\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0438\u0434\u0435\u043c \u043d\u0430 <a href=\"http:\/\/localhost:5050\/\" rel=\"noopener noreferrer nofollow\">http:\/\/localhost:5050\/<\/a> \u0438 \u0432\u0445\u043e\u0434\u0438\u043c \u0432 pgadmin \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0432\u0445\u043e\u0434\u0430 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0435 \u0432 docker-compose.yml<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/52d\/2e8\/16d\/52d2e816ddb63669ca7aab54d9b3b66b.png\" width=\"1143\" height=\"564\"><\/figure>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/314\/056\/f93\/314056f93a8d1f7e53a782d822e7b0ef.png\" width=\"922\" height=\"606\"><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1cf\/cb5\/b06\/1cfcb5b06b0f71dba8b48a0b8684393b.png\" width=\"804\" height=\"601\"><\/figure>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u0432 \u0437\u0430\u043f\u0440\u043e\u0441 SELECT count(*) FROM accounts; \u043c\u043e\u0436\u043d\u043e \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 10000.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/71a\/f65\/7a0\/71af657a0796f78a20d3619a709e18ab.png\" width=\"789\" height=\"516\"><\/figure>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e postman \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c get \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 http:\/\/localhost:8081\/api\/v1\/accounts\/emailSendMultipleQueries  <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/af6\/97b\/86b\/af697b86b6c50b2ee5c08ad995b0f2ee.png\" width=\"941\" height=\"392\"><\/figure>\n<p>\u0418 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043c\u043d\u043e\u0433\u043e sql \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 9366 \u043c\u0438\u043b\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/476\/6f4\/890\/4766f48904f74173a57ca9283c5f2516.png\" width=\"910\" height=\"511\"><\/figure>\n<p>\u041f\u043e\u0432\u0442\u043e\u0440\u0438\u043c \u044d\u0442\u043e \u0435\u0449\u0435 2 \u0440\u0430\u0437\u0430 \u0438 \u0432\u044b\u0432\u0435\u0434\u0435\u043c \u0441\u0440\u0435\u0434\u043d\u044e\u044e. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0442\u0430\u043a\u0438\u0435 (9366+8863+9165)\/3=9131.<\/p>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0435\u0440\u0435\u0434\u0435\u043b\u0430\u0435\u043c \u043d\u0430\u0448\u0435 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u043b \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u043d\u0435\u0439 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442 \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0448\u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430.<\/p>\n<p>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 AccountRepository \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c:<\/p>\n<pre><code class=\"java\">    @Query(\"select a.email from Account a where a.email IN(:emails)\")     List&lt;String&gt; emailExists(@Param(\"emails\") List&lt;String&gt; emails);<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e <a class=\"mention\" href=\"\/users\/Query\">@Query<\/a> \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u044b \u0441\u0440\u0430\u0437\u0443 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0432\u0435\u0441\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u044b\u0445 \u0430\u0434\u0440\u0435\u0441\u043e\u0432 \u0438 \u0434\u0435\u043b\u0430\u0435\u043c \u043f\u043e\u0438\u0441\u043a \u0430\u0434\u0440\u0435\u0441\u0430 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 AccountService \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c:<\/p>\n<pre><code class=\"java\">List&lt;String&gt; getEmailExistsInDBSingleQueries(List&lt;String&gt; targetEmailList);<\/code><\/pre>\n<p>\u0412 \u043a\u043b\u0430\u0441\u0441\u0435 AccountServiceImpl \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434:<\/p>\n<pre><code class=\"java\">    @Override     public List&lt;String&gt; getEmailExistsInDBSingleQueries(List&lt;String&gt; targetEmailList) {         return accountRepository.emailExists(targetEmailList);     }<\/code><\/pre>\n<p> \u0418 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 NotificationService \u0432\u044b\u0437\u043e\u0432\u0435\u043c \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0438 \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0435\u043c \u0437\u0430 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b\u0441\u044f.<\/p>\n<pre><code class=\"java\">    public void sendEmailSingleQueries(){         List&lt;String&gt; targetEmailList = ConstantData.LIST_OF_EMAILS_TO_SEND;         StopWatch stopWatch = new StopWatch();         stopWatch.start();         List&lt;String&gt; listEmailToSend = accountService.getEmailExistsInDBSingleQueries(targetEmailList);         \/\/email send code         stopWatch.stop();         System.out.println(\"Time has passed with to check if an account with this email exists with single queries, ms: \" + stopWatch.getTime());         System.out.println(\"Size of emails list: \" + listEmailToSend.size());     }<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 &#8212; \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u043c \u043a\u043b\u0430\u0441\u0441 AccountController get \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c \u043f\u043e \u0432\u044b\u0437\u043e\u0432\u0443 \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430.<\/p>\n<pre><code class=\"java\">    @GetMapping(\"\/emailSendSingleQueries\")     @ResponseStatus(HttpStatus.OK)     public void emailSendSingleQueries() {         log.info(\"Send emails with single queries\");         notificationService.sendEmailSingleQueries();     }<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u0434 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0437\u0430\u0439\u0434\u0435\u043c \u0432 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0443\u0434\u0430\u043b\u0438\u043c \u0432 \u043d\u0435\u0439 \u0432\u0441\u0435 \u0437\u0430\u043f\u0438\u0441\u0438.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/661\/1cf\/e25\/6611cfe25242957b8ceb8c492c5d4bde.png\" width=\"1015\" height=\"493\"><\/figure>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438\u0434\u0435\u043c \u0432 postman \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c get \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430  http:\/\/localhost:8081\/api\/v1\/accounts\/emailSendSingleQueries  <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/14c\/b29\/e6e\/14cb29e6e088927813039ee2beb72038.png\" width=\"917\" height=\"400\"><\/figure>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u043c\u0435\u0442\u043e\u0434 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b \u043e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u043e, \u0438\u0434\u0435\u043c \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0438 \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0431\u044b\u043b \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0448\u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0430 129 \u043c\u0438\u043b\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a32\/e90\/26d\/a32e9026d70a8def4d32f48a3dfc0b8a.png\" width=\"1045\" height=\"245\"><\/figure>\n<p>\u041f\u043e\u0432\u0442\u043e\u0440\u0438\u043c \u0435\u0449\u0435 2 \u0440\u0430\u0437\u0430 \u0438 \u0432\u044b\u0432\u0435\u0434\u0435\u043c \u0441\u0440\u0435\u0434\u043d\u044e\u044e. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442 (129+48+47)\/3=75.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043c\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u043a\u043e\u0434\u0435 \u0443\u043b\u0443\u0447\u0448\u0438\u043b\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0448\u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u043f\u043e \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044e \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 <strong>\u0432 122 \u0440\u0430\u0437\u0430<\/strong> (9131\/75).<\/p>\n<p>\u041d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u044f \u0445\u043e\u0442\u0435\u043b \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 &#171;\u0432\u043e\u043b\u0448\u0435\u0431\u043d\u044b\u0445&#187; \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0430\u0435\u0442 \u043d\u0430\u043c Spring Data JPA \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u043f\u0440\u0430\u0432\u0434\u0430\u043d\u043e, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043a\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u043c\u0435\u043d\u044b \u043c\u043d\u043e\u0433\u043e\u043a\u0440\u0430\u0442\u043d\u044b\u0445 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0439 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0434\u043d\u0438\u043c sql \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0441\u044f \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u043a \u043d\u0430\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442.<\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0432\u0441\u0435\u043c, \u043a\u0442\u043e \u0434\u043e\u0447\u0438\u0442\u0430\u043b \u0434\u043e \u043a\u043e\u043d\u0446\u0430.<\/p>\n<p>\u0412\u043e\u0442 <a href=\"https:\/\/github.com\/mista1984gmail\/spring-data-jpa-multiple-single-queries\" rel=\"noopener noreferrer nofollow\">\u0441\u0441\u044b\u043b\u043a\u0430 <\/a>\u043d\u0430 \u043f\u0440\u043e\u0435\u043a\u0442.<\/p>\n<p>\u0412\u0441\u0435\u043c \u043f\u043e\u043a\u0430. <\/p>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/740446\/\"> https:\/\/habr.com\/ru\/articles\/740446\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043a\u043e\u0441\u043d\u0443\u0441\u044c \u0442\u0435\u043c\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043a\u0430\u043a \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u043a\u043e\u0434\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0442 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0437\u0430 \u0441\u0447\u0435\u0442 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439.<\/p>\n<p>\u0418 \u0442\u0430\u043a \u043f\u043e\u0435\u0445\u0430\u043b\u0438.<\/p>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0442\u0430\u043a\u043e\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u0435: \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043a\u0430\u043a\u0430\u044f-\u0442\u043e \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0430\u043c\u0438, \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0430\u043a\u043a\u0430\u0443\u0442\u0435 \u0435\u0441\u0442\u044c \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u0430\u044f \u043f\u043e\u0447\u0442\u0430. \u041a \u043d\u0430\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u0441 \u043e\u0442\u0434\u0435\u043b\u0430 \u043c\u0430\u0440\u043a\u0435\u0442\u0438\u043d\u0433\u0430 \u0438 \u0433\u043e\u0432\u043e\u0440\u044f\u0442 &#171;\u0412\u043e\u0442 \u0432\u0430\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u0447\u0442\u043e\u0432\u044b\u0445 \u0430\u0434\u0440\u0435\u0441\u043e\u0432, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u0439\u0442\u0438\u0441\u044c \u043f\u043e \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0430\u043a\u043a\u0430\u0443\u0442\u0430\u043c\u0438, \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0435\u0441\u0442\u044c \u043b\u0438 \u0442\u0430\u043a\u0438\u0435 \u0430\u0434\u0440\u0435\u0441\u0430, \u0438 \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c &#8212; \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043d\u0430 \u044d\u0442\u0443 \u043f\u043e\u0447\u0442\u0443 \u043f\u0438\u0441\u044c\u043c\u043e&#187;.<\/p>\n<p>\u0412\u0440\u043e\u0434\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u043d\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0435, \u043d\u043e \u0435\u0441\u043b\u0438 \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0430\u043a\u043a\u0430\u0443\u0442\u043e\u0432 \u043d\u0435 \u0441\u043e\u0442\u043d\u0438, \u0430 \u0442\u044b\u0441\u044f\u0447\u0438 \u0438\u043b\u0438 \u0434\u0435\u0441\u044f\u0442\u043a\u0438 \u0442\u044b\u0441\u044f\u0447, \u0442\u043e \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043d\u0438\u0437\u0438\u0442\u044c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0448\u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u043f\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439.<\/p>\n<p>\u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0417\u0430\u0439\u0434\u0435\u043c \u043d\u0430 <a href=\"https:\/\/start.spring.io\/\" rel=\"noopener noreferrer nofollow\">https:\/\/start.spring.io\/<\/a> \u0438 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0440\u043e\u0435\u043a\u0442.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041e\u0442\u043a\u0440\u043e\u0435\u043c \u0435\u0433\u043e \u0432 \u0441\u0440\u0435\u0434\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c pom.xml<\/p>\n<pre><code class=\"java\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt; &lt;project xmlns=\"http:\/\/maven.apache.org\/POM\/4.0.0\" xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi:schemaLocation=\"http:\/\/maven.apache.org\/POM\/4.0.0 https:\/\/maven.apache.org\/xsd\/maven-4.0.0.xsd\"&gt; &lt;modelVersion&gt;4.0.0&lt;\/modelVersion&gt; &lt;parent&gt; &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt; &lt;artifactId&gt;spring-boot-starter-parent&lt;\/artifactId&gt; &lt;version&gt;3.1.0&lt;\/version&gt; &lt;relativePath\/&gt; &lt;!-- lookup parent from repository --&gt; &lt;\/parent&gt; &lt;groupId&gt;com.example&lt;\/groupId&gt; &lt;artifactId&gt;spring-data-jpa-multiple-single-queries&lt;\/artifactId&gt; &lt;version&gt;0.0.1-SNAPSHOT&lt;\/version&gt; &lt;name&gt;spring-data-jpa-multiple-single-queries&lt;\/name&gt; &lt;description&gt;Demo project for Spring Boot&lt;\/description&gt; &lt;properties&gt; &lt;java.version&gt;17&lt;\/java.version&gt; &lt;\/properties&gt; &lt;dependencies&gt; &lt;!--JPA--&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt; &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;\/artifactId&gt; &lt;\/dependency&gt; &lt;!--WEB--&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt; &lt;artifactId&gt;spring-boot-starter-web&lt;\/artifactId&gt; &lt;\/dependency&gt; &lt;!--DATABASE--&gt; &lt;dependency&gt; &lt;groupId&gt;org.postgresql&lt;\/groupId&gt; &lt;artifactId&gt;postgresql&lt;\/artifactId&gt; &lt;scope&gt;runtime&lt;\/scope&gt; &lt;\/dependency&gt; &lt;!--LIQUIBASE--&gt; &lt;dependency&gt; &lt;groupId&gt;org.liquibase&lt;\/groupId&gt; &lt;artifactId&gt;liquibase-core&lt;\/artifactId&gt; &lt;\/dependency&gt; &lt;!--LOMBOK--&gt; &lt;dependency&gt; &lt;groupId&gt;org.projectlombok&lt;\/groupId&gt; &lt;artifactId&gt;lombok&lt;\/artifactId&gt; &lt;optional&gt;true&lt;\/optional&gt; &lt;\/dependency&gt; &lt;!--TESTING--&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt; &lt;artifactId&gt;spring-boot-starter-test&lt;\/artifactId&gt; &lt;scope&gt;test&lt;\/scope&gt; &lt;\/dependency&gt; &lt;!--OTHERS--&gt; &lt;dependency&gt; &lt;groupId&gt;com.github.javafaker&lt;\/groupId&gt; &lt;artifactId&gt;javafaker&lt;\/artifactId&gt; &lt;version&gt;1.0.2&lt;\/version&gt; &lt;\/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.apache.commons&lt;\/groupId&gt; &lt;artifactId&gt;commons-lang3&lt;\/artifactId&gt; &lt;version&gt;3.9&lt;\/version&gt; &lt;\/dependency&gt; &lt;\/dependencies&gt;  &lt;build&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt; &lt;artifactId&gt;spring-boot-maven-plugin&lt;\/artifactId&gt; &lt;configuration&gt; &lt;excludes&gt; &lt;exclude&gt; &lt;groupId&gt;org.projectlombok&lt;\/groupId&gt; &lt;artifactId&gt;lombok&lt;\/artifactId&gt; &lt;\/exclude&gt; &lt;\/excludes&gt; &lt;\/configuration&gt; &lt;\/plugin&gt; &lt;\/plugins&gt; &lt;\/build&gt;  &lt;\/project&gt; <\/code><\/pre>\n<p>\u0411\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c postgresql, \u0434\u043b\u044f \u043d\u0430\u043a\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 \u043d\u0435\u0439 &#8212; liquibase.<\/p>\n<p>\u0411\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0434\u043d\u0438\u043c\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e docker-\u0430, \u0442\u0430\u043a\u0436\u0435 \u0432 \u0434\u043e\u043a\u0435\u0440\u0435 \u043f\u043e\u0434\u043d\u0438\u043c\u0435\u043c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0441 pgadmin &#8212; \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0431\u0430\u0437\u0435.<\/p>\n<p>\u0421\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043a\u043e\u0434 \u0441 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438.<\/p>\n<p>\u0412 \u043a\u043e\u0440\u043d\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043d\u0430\u043f\u0438\u0448\u0435\u043c docker-compose.yml \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435\u043c:<\/p>\n<pre><code class=\"java\">services:   service-db:     image: postgres:14.7-alpine     environment:       POSTGRES_USER: username       POSTGRES_PASSWORD: password     ports:       - \"15432:5432\"     volumes:       - .\/infrastructure\/db\/create_db.sql:\/docker-entrypoint-initdb.d\/create_db.sql       - db-data:\/var\/lib\/postgresql\/data     restart: unless-stopped    pgadmin:     container_name: pgadmin4_container     image: dpage\/pgadmin4:7     restart: always     environment:       PGADMIN_DEFAULT_EMAIL: admin@admin.com       PGADMIN_DEFAULT_PASSWORD: root     ports:       - \"5050:80\"     volumes:       - pgadmin-data:\/var\/lib\/pgadmin  volumes:   db-data:   pgadmin-data:<\/code><\/pre>\n<p>\u0411\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 accounts_database \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043a\u0440\u0438\u043f\u0442\u0430, \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u0432 \u043f\u0430\u043f\u043a\u0435 infrastructure\/db<\/p>\n<pre><code class=\"java\">create database accounts_database;<\/code><\/pre>\n<p>\u041e\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0441\u044f \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0432 docker-\u0435. \u0422\u0430\u043a\u0436\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u043d\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0441 \u043d\u0430\u0448\u0435\u0439 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u043e\u043d\u0438 \u043d\u0435 \u043f\u043e\u0442\u0435\u0440\u044f\u043b\u0438\u0441\u044c.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u0430\u0448\u0443 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c, \u0442\u043e \u0435\u0441\u0442\u044c \u0430\u043a\u043a\u0430\u0443\u043d\u0442.<\/p>\n<pre><code class=\"java\">@Data @Builder @Entity @NoArgsConstructor @AllArgsConstructor @Table(name = \"accounts\") public class Account {     @Id     @Column(name = \"id\")     @GeneratedValue(strategy = GenerationType.IDENTITY)     private Long id;     @Column(name=\"username\",             nullable = false)     private String username;     @Column(name=\"email\",             nullable = false)     private String email;     @Column(name=\"created_at\",             nullable = false)     private LocalDate createdAt;      public Account(String username, String email, LocalDate createdAt) {         this.username = username;         this.email = email;         this.createdAt = createdAt;     } }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043f\u0430\u043f\u043e\u043a \u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0430\u0439\u043b\u044b \u0434\u043b\u044f \u043d\u0430\u043a\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<figure class=\"\"><\/figure>\n<p>2023-06-06-1-create-table-accounts.xml<\/p>\n<pre><code class=\"java\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\" ?&gt; &lt;databaseChangeLog         xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"         xmlns=\"http:\/\/www.liquibase.org\/xml\/ns\/dbchangelog\"         xsi:schemaLocation=\"http:\/\/www.liquibase.org\/xml\/ns\/dbchangelog http:\/\/www.liquibase.org\/xml\/ns\/dbchangelog\/dbchangelog-3.1.xsd\"&gt;      &lt;changeSet logicalFilePath=\"2023-06-06-1-create-table-accounts\"                id=\"2023-06-06-1-create-table-accounts\" author=\"s.m\"&gt;         &lt;createTable tableName=\"accounts\"&gt;             &lt;column name=\"id\" type=\"serial\"&gt;                 &lt;constraints nullable=\"false\" primaryKey=\"true\"\/&gt;             &lt;\/column&gt;             &lt;column name=\"username\" type=\"varchar(255)\"&gt;                 &lt;constraints nullable=\"false\"\/&gt;             &lt;\/column&gt;             &lt;column name=\"email\" type=\"varchar(255)\"&gt;                 &lt;constraints nullable=\"false\"\/&gt;             &lt;\/column&gt;             &lt;column name=\"created_at\" type=\"date\"&gt;                 &lt;constraints nullable=\"false\"\/&gt;             &lt;\/column&gt;         &lt;\/createTable&gt;     &lt;\/changeSet&gt; &lt;\/databaseChangeLog&gt;<\/code><\/pre>\n<p>cumulative.xml<\/p>\n<pre><code class=\"java\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\" ?&gt; &lt;databaseChangeLog         xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"         xmlns=\"http:\/\/www.liquibase.org\/xml\/ns\/dbchangelog\"         xsi:schemaLocation=\"http:\/\/www.liquibase.org\/xml\/ns\/dbchangelog http:\/\/www.liquibase.org\/xml\/ns\/dbchangelog\/dbchangelog-3.1.xsd\"&gt;      &lt;include file=\"2023-06-06-1-create-table-accounts.xml\" relativeToChangelogFile=\"true\" \/&gt; &lt;\/databaseChangeLog&gt;<\/code><\/pre>\n<p>db.changelog-master.xml<\/p>\n<pre><code class=\"java\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\" ?&gt; &lt;databaseChangeLog         xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"         xmlns=\"http:\/\/www.liquibase.org\/xml\/ns\/dbchangelog\"         xsi:schemaLocation=\"http:\/\/www.liquibase.org\/xml\/ns\/dbchangelog http:\/\/www.liquibase.org\/xml\/ns\/dbchangelog\/dbchangelog-3.1.xsd\"&gt;      &lt;include file=\"v.1.0.0\/cumulative.xml\" relativeToChangelogFile=\"true\" \/&gt;  &lt;\/databaseChangeLog&gt;<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 AccountRepository \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0441 \u043d\u0430\u0448\u0435\u0439 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c\u044e \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<pre><code class=\"java\">@Repository public interface AccountRepository extends JpaRepository&lt;Account, Long&gt; { }<\/code><\/pre>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0448\u0430\u0433\u043e\u043c \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0430\u0439\u043b application.yml<\/p>\n<pre><code class=\"java\">server:   port: 8081 spring:   datasource:     url: jdbc:postgresql:\/\/${DB_HOST:localhost}:${DB_PORT:15432}\/accounts_database     username: username     password: password   liquibase:     enabled: true     drop-first: false     change-log: classpath:db\/changelog\/db.changelog-master.xml     default-schema: public   jpa:     show-sql: true     properties:       hibernate:         format_sql: true<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u043d\u0430\u0448\u0435\u0439 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c liquibase \u0438 \u0437\u0430\u0434\u0430\u0435\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438, \u0447\u0442\u043e\u0431\u044b \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0432\u044b\u0432\u043e\u0434\u0438\u043b\u0438\u0441\u044c sql \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043a\u0430\u043a\u0438\u043c\u0438-\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u0441 \u043d\u0438\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c.<\/p>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438 \u0432 \u043d\u0430\u0448\u0435\u0439 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 10 000 \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u043e\u0432, \u0430 \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0435\u0441\u0442\u044c \u043b\u0438 \u0442\u0430\u043a\u0438\u0435 email-\u044b \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c 5 000 \u0430\u0434\u0440\u0435\u0441\u043e\u0432 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0439 \u043f\u043e\u0447\u0442\u044b.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043b\u0430\u0441\u0441 ConstantData \u0432 \u043f\u0430\u043f\u043a\u0435 config.<\/p>\n<pre><code class=\"java\">public class ConstantData {      public final static int NUMBER_ACCOUNTS = 10_000;     public final static int NUMBER_OF_EMAILS_TO_SEND = (NUMBER_ACCOUNTS \/ 2) + 1;     public final static List&lt;String&gt; LIST_OF_EMAILS_TO_SEND = createListOfEmails();      static List&lt;String&gt; createListOfEmails() {         Faker faker = new Faker();         List&lt;String&gt; emailsToSend = new ArrayList&lt;&gt;();         for (int i = 0; i &lt; NUMBER_OF_EMAILS_TO_SEND; i++) {             emailsToSend.add(faker.internet().emailAddress());         }         return emailsToSend;     } }<\/code><\/pre>\n<p>\u0412 \u043c\u0435\u0442\u043e\u0434\u0435 createListOfEmails() \u043c\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 javafaker \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c 5000 \u0430\u0434\u0440\u0435\u0441\u043e\u0432 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0439 \u043f\u043e\u0447\u0442\u044b.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u043a\u043b\u0430\u0441\u0441 DataLoader.<\/p>\n<pre><code class=\"java\">@Component public class DataLoader {      @Bean     public CommandLineRunner loadDataAccount(AccountRepository accountRepository) {         return (args) -&gt; {             Faker faker = new Faker();             for (int i = 1; i &lt;= ConstantData.NUMBER_ACCOUNTS; i++) {                 String username = faker.name().username();                 String email = \"\";                 if (i % 2 == 0) {                     email = ConstantData.LIST_OF_EMAILS_TO_SEND.get(i \/ 2);                 } else {                     email = faker.internet().emailAddress();                 }                 Account account = Account.builder()                         .username(username)                         .email(email)                         .createdAt(LocalDate.of(2022, Month.JANUARY, 1).plusDays(faker.number().numberBetween(1, 365)))                         .build();                 accountRepository.save(account);             }         };     } } <\/code><\/pre>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 loadDataAccount \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c 10 000<\/p>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-348447","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/348447","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=348447"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/348447\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=348447"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=348447"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=348447"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}