{"id":314349,"date":"2020-12-04T21:00:44","date_gmt":"2020-12-04T21:00:44","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=314349"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=314349","title":{"rendered":"\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 Spring Data JDBC"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<blockquote>\n<p><strong>\u0414\u043b\u044f \u0431\u0443\u0434\u0443\u0449\u0438\u0445 \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u043e\u0432 \u043a\u0443\u0440\u0441\u0430 <\/strong><a href=\"https:\/\/otus.pw\/FUU0\/\"><strong>&#171;Java Developer. Professional&#187;<\/strong><\/a><strong> \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0433\u043e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u0435\u043c \u043f\u0440\u0438\u043d\u044f\u0442\u044c \u0443\u0447\u0430\u0441\u0442\u0438\u0435 \u0432 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u043c \u0443\u0440\u043e\u043a\u0435 \u043d\u0430 \u0442\u0435\u043c\u0443 <\/strong><a href=\"https:\/\/otus.pw\/z6ET\/\"><strong>&#171;\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 Spring Data jdbc&#187;<\/strong><\/a>  <\/p>\n<\/blockquote>\n<hr>\n<p>Spring Data JDBC \u0431\u044b\u043b <a href=\"https:\/\/spring.io\/blog\/2018\/09\/17\/introducing-spring-data-jdbc\"><u>\u0430\u043d\u043e\u043d\u0441\u0438\u0440\u043e\u0432\u0430\u043d<\/u><\/a> \u0432 2018 \u0433\u043e\u0434\u0443. \u0426\u0435\u043b\u044c\u044e \u0431\u044b\u043b\u043e \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0443 JPA, \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044f \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0430\u043c Spring Data. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0443\u0437\u043d\u0430\u0442\u044c \u043e \u043c\u043e\u0442\u0438\u0432\u0430\u0445, \u043b\u0435\u0436\u0430\u0449\u0438\u0445 \u0432 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432 <a href=\"https:\/\/docs.spring.io\/spring-data\/jdbc\/docs\/current\/reference\/html\/#jdbc.why\"><u>\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/u><\/a>.&nbsp;<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u043e\u043a\u0430\u0436\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Spring Data JDBC. \u0417\u0434\u0435\u0441\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0433\u043e \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0430, \u043d\u043e, \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0445\u0432\u0430\u0442\u0438\u0442, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e. \u041e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e, \u0435\u0441\u043b\u0438 \u0432\u044b \u0443\u0436\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0441\u043e Spring Data JPA. \u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 \u0432 <a href=\"https:\/\/github.com\/lumberjackdev\/getting-started-spring-data-jdbc\"><u>github<\/u><\/a>.<\/p>\n<p>\u0414\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u0441\u0442\u0430\u0440\u0442\u0430 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b <a href=\"https:\/\/github.com\/lumberjackdev\/spring-boot-java-11-postgres-template\"><u>\u044d\u0442\u043e\u0442 \u0448\u0430\u0431\u043b\u043e\u043d<\/u><\/a>.<\/p>\n<h4>\u041f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430<\/h4>\n<p>\u0418\u0437 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u044b <code>data-jdbc<\/code> \u2014 \u0441\u0442\u0430\u0440\u0442\u0435\u0440, <code>flyway<\/code> \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0445\u0435\u043c\u043e\u0439 \u0438 \u0434\u0440\u0430\u0439\u0432\u0435\u0440 <code>postgres<\/code> \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<pre><code class=\"javascript\">\/\/ build.gradle dependencies {     implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'      implementation 'org.flywaydb:flyway-core'      runtimeOnly 'org.postgresql:postgresql' }<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<pre><code class=\"kotlin\"># application.yml spring:   application:     name: template-app   datasource:     url: jdbc:postgresql:\/\/localhost:5432\/demo_app?currentSchema=app     username: app_user     password: change_me     driver-class-name: org.postgresql.Driver<\/code><\/pre>\n<h4>\u041c\u0430\u043f\u043f\u0438\u043d\u0433 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439<\/h4>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443:<\/p>\n<pre><code class=\"javascript\">create table book (     id varchar(32) not null,     title varchar(255) not null,     author varchar(255),     isbn varchar(15),     published_date date,     page_count integer,     primary key (id) );<\/code><\/pre>\n<p>\u0418 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 java-\u043a\u043b\u0430\u0441\u0441 (\u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e <code>@Id<\/code> \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0438\u0437 <code>org.springframework.data.annotation.Id<\/code>):<\/p>\n<pre><code class=\"javascript\">\/\/ Book.java public class Book {     @Id     private String id;     private String title;     private String author;     private String isbn;     private Instant publishedDate;     private Integer pageCount; }<\/code><\/pre>\n<p><em>\u041e\u0434\u043d\u0430\u043a\u043e, \u0435\u0441\u043b\u0438 \u043c\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c <\/em><a href=\"https:\/\/github.com\/lumberjackdev\/getting-started-spring-data-jdbc\/blob\/master\/src\/test\/java\/com\/lumberjackdev\/jdbcexample\/repository\/BookRepositoryTest.java\"><em><u>\u0442\u0435\u0441\u0442<\/u><\/em><\/a><em>:<\/em><\/p>\n<pre><code class=\"javascript\">\/\/ BookRepositoryTest.java @Test void canSaveBook() {     var book = Book.builder().author(\"Steven Erikson\").title(\"Gardens of the Moon\").build();     var savedBook = bookRepository.save(book);      assertThat(savedBook.getId()).isNotBlank();     assertThat(savedBook.getAuthor()).isEqualTo(book.getAuthor());     assertThat(savedBook.getTitle()).isEqualTo(book.getTitle());      assertThat(savedBook).isEqualTo(bookRepository.findById(savedBook.getId()).get()); }<\/code><\/pre>\n<p>\u0422\u043e \u0443\u0432\u0438\u0434\u0438\u043c \u043e\u0448\u0438\u0431\u043a\u0443 \u2014 ERROR: null value in column &#171;id&#187; violates not-null constraint. \u042d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u044b \u043d\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 \u043d\u0438 \u0441\u043f\u043e\u0441\u043e\u0431 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 id \u043d\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. \u041f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 Spring Data JDBC \u0432 \u0447\u0430\u0441\u0442\u0438 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u0432 <a href=\"https:\/\/docs.spring.io\/spring-data\/jdbc\/docs\/current\/reference\/html\/#jdbc.entity-persistence.id-generation\"><u>\u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f<\/u><\/a> \u043e\u0442 Spring Data JPA. \u0412 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c <code>ApplicationListener<\/code> \u0434\u043b\u044f <code>BeforeSaveEvent<\/code>:<\/p>\n<pre><code class=\"javascript\">\/\/ PersistenceConfig.java @Bean public ApplicationListener&lt;BeforeSaveEvent&gt; idGenerator() {     return event -&gt; {         var entity = event.getEntity();         if (entity instanceof Book) {             ((Book) entity).setId(UUID.randomUUID().toString());         }     }; }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0442\u0435\u0441\u0442 \u043f\u0440\u043e\u0439\u0434\u0435\u0442, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u043e\u043b\u0435 Id \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f. \u041f\u043e\u043b\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 \u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u0432 <a href=\"https:\/\/docs.spring.io\/spring-data\/jdbc\/docs\/current\/reference\/html\/#jdbc.events\"><u>\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/u><\/a>.<\/p>\n<h3>\u041c\u0435\u0442\u043e\u0434\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432&nbsp;<\/h3>\n<p>\u041e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 Spring Data \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f\u0445. Spring Data JDBC \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0437\u0434\u0435\u0441\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434. \u0414\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043c\u0435\u0442\u043e\u0434 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 <code>BookRepository<\/code>:<\/p>\n<pre><code class=\"javascript\">Optional&lt;Book&gt; findByTitle(String title);<\/code><\/pre>\n<p>\u0418 \u0435\u0441\u043b\u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0442\u0435\u0441\u0442:<\/p>\n<pre><code class=\"javascript\">@Test void canFindBookByTitle() {     var title = \"Gardens of the Moon\";     var book = Book.builder().author(\"Steven Erikson\").title(title).build();     var savedBook = bookRepository.save(book);     assertThat(bookRepository.findByTitle(title).get()).isEqualTo(savedBook); }<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u043c \u043e\u0448\u0438\u0431\u043a\u0443 \u2014 <code>Caused by: java.lang.IllegalStateException: No query specified on findByTitle<\/code>. \u0412 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f Spring Data JDBC <a href=\"https:\/\/docs.spring.io\/spring-data\/jdbc\/docs\/current\/reference\/html\/#jdbc.query-methods.at-query\"><u>\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442<\/u><\/a> \u0442\u043e\u043b\u044c\u043a\u043e \u044f\u0432\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u0437\u0430\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0435 \u0447\u0435\u0440\u0435\u0437 @Query. \u041d\u0430\u043f\u0438\u0448\u0435\u043c sql-\u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430:<\/p>\n<pre><code class=\"javascript\">@Query(\"select * from Book b where b.title = :title\") Optional&lt;Book&gt; findByTitle(@Param(\"title\") String title);<\/code><\/pre>\n<p>\u0422\u0435\u0441\u0442 \u043f\u0440\u043e\u0439\u0434\u0435\u043d! \u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0439\u0442\u0435 \u043e\u0431 \u044d\u0442\u043e\u043c \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u0432.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0447\u0438\u043a\u0430: \u0432 <a href=\"https:\/\/docs.spring.io\/spring-data\/jdbc\/docs\/current\/reference\/html\/#new-features.2-0-0\"><u>Spring Data JDBC 2.0<\/u><\/a> \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043f\u043e <a href=\"https:\/\/docs.spring.io\/spring-data\/jdbc\/docs\/current\/reference\/html\/#jdbc.query-methods\"><u>\u0438\u043c\u0435\u043d\u0430\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u0432<\/u><\/a>.&nbsp;<\/p>\n<h3>\u0421\u0432\u044f\u0437\u0438<\/h3>\n<p>\u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043e \u0441\u0432\u044f\u0437\u044f\u043c\u0438 Spring Data JDBC \u0442\u0430\u043a\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434. \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043b\u0435\u043d\u0438\u0432\u0430\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u0430 \u0441\u0432\u044f\u0437\u044c \u0432 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0439\u0442\u0435 \u0435\u0435 \u0442\u0443\u0434\u0430. \u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0430 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0439 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (Domain Driven Design), \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c, \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043a\u043e\u0440\u043d\u044f\u043c\u0438 \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u043e\u0432, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0434\u043e \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043a\u043e\u0440\u043d\u0438 \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u043e\u0432 \u0442\u044f\u043d\u0443\u043b\u0438 \u0437\u0430 \u0441\u043e\u0431\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0434\u0440\u0443\u0433\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432.<\/p>\n<h4>\u041e\u0434\u0438\u043d-\u043a-\u043e\u0434\u043d\u043e\u043c\u0443<\/h4>\n<p>\u0414\u043b\u044f \u0441\u0432\u044f\u0437\u0435\u0439 &#171;\u043e\u0434\u0438\u043d-\u043a-\u043e\u0434\u043d\u043e\u043c\u0443&#187; \u0438 &#171;\u043e\u0434\u0438\u043d-\u043a\u043e-\u043c\u043d\u043e\u0433\u0438\u043c&#187; \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f <code>@MappedCollection<\/code>. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 &#171;\u043e\u0434\u0438\u043d-\u043a-\u043e\u0434\u043d\u043e\u043c\u0443&#187;. \u041a\u043b\u0430\u0441\u0441&nbsp;<code>UserAccount<\/code> \u0431\u0443\u0434\u0435\u0442 \u0441\u0441\u044b\u043b\u0430\u0442\u044c\u0441\u044f \u043d\u0430 <code>Address<\/code>. \u0412\u043e\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 sql:<\/p>\n<pre><code class=\"sql\">create table address (     id      varchar(36) not null,     city    varchar(255),     state   varchar(255),     street  varchar(255),     zipcode varchar(255),     primary key (id) );  create table user_account (     id         varchar(36)  not null,     name       varchar(255) not null,     email      varchar(255) not null,     address_id varchar(36),     primary key (id),     constraint fk_user_account_address_id foreign key (address_id) references address (id) );<\/code><\/pre>\n<p>\u041a\u043b\u0430\u0441\u0441 <code>UserAccount<\/code> \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"sql\">\/\/ UserAccount.java public class UserAccount implements GeneratedId {     \/\/ ...other fields     @MappedCollection(idColumn = \"id\")     private Address address; }<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043e\u043f\u0443\u0449\u0435\u043d\u044b \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u043e\u043b\u044f, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043c\u0430\u043f\u043f\u0438\u043d\u0433 <code>address<\/code>. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 <code>idColumn<\/code> \u2014 \u044d\u0442\u043e \u0438\u043c\u044f \u043f\u043e\u043b\u044f \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 <code>Address<\/code>. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 <code>Address<\/code> \u043d\u0435\u0442 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043a\u043b\u0430\u0441\u0441 <code>UserAccount<\/code>, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <code>UserAccount<\/code>. \u042d\u0442\u043e \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0432 \u0442\u0435\u0441\u0442\u0435:<\/p>\n<pre><code class=\"sql\">\/\/UserAccountRepositoryTest.java @Test void canSaveUserWithAddress() {     var address = stubAddress();     var newUser = stubUser(address);      var savedUser = userAccountRepository.save(newUser);      assertThat(savedUser.getId()).isNotBlank();     assertThat(savedUser.getAddress().getId()).isNotBlank();      var foundUser = userAccountRepository.findById(savedUser.getId()).orElseThrow(IllegalStateException::new);     var foundAddress = addressRepository.findById(foundUser.getAddress().getId()).orElseThrow(IllegalStateException::new);      assertThat(foundUser).isEqualTo(savedUser);     assertThat(foundAddress).isEqualTo(savedUser.getAddress()); }<\/code><\/pre>\n<h4>\u041e\u0434\u0438\u043d-\u043a\u043e-\u043c\u043d\u043e\u0433\u0438\u043c<\/h4>\n<p>\u0412\u043e\u0442 sql, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0441\u0432\u044f\u0437\u0438 &#171;\u043e\u0434\u0438\u043d-\u043a\u043e-\u043c\u043d\u043e\u0433\u0438\u043c&#187;:<\/p>\n<pre><code class=\"sql\">create table warehouse (     id       varchar(36) not null,     location varchar(255),     primary key (id) );  create table inventory_item (     id        varchar(36) not null,     name      varchar(255),     count     integer,     warehouse varchar(36),     primary key (id),     constraint fk_inventory_item_warehouse_id foreign key (warehouse) references warehouse (id) );<\/code><\/pre>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0430 \u0441\u043a\u043b\u0430\u0434\u0435 (warehouse) \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0442\u043e\u0432\u0430\u0440\u043e\u0432\/\u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 (inventoryitems). \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 <code>Warehouse<\/code> \u043c\u044b \u0442\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>@MappedCollection<\/code> \u0434\u043b\u044f <code>InventoryItem<\/code>:<\/p>\n<pre><code class=\"sql\">public class Warehouse {     \/\/ ...other fields     @MappedCollection     Set&lt;InventoryItem&gt; inventoryItems = new HashSet&lt;&gt;();      public void addInventoryItem(InventoryItem inventoryItem) {         var itemWithId = inventoryItem.toBuilder().id(UUID.randomUUID().toString()).build();         this.inventoryItems.add(itemWithId);     } }  public class InventoryItem {     @Id     private String id;     private String name;     private int count; }<\/code><\/pre>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u044b \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043f\u043e\u043b\u0435 <code>id<\/code> \u0432\u043e \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0435 <code>addInventoryItem<\/code>. \u041c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c <code>ApplicationListener<\/code> \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0430 <code>Warehouse<\/code> \u0441 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 <code>BeforeSaveEvent<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043f\u043e\u043b\u0435 <code>id<\/code> \u0434\u043b\u044f \u0432\u0441\u0435\u0445 <code>InventoryItem<\/code>. \u0412\u0430\u043c \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0432 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u0442\u0430\u043a, \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0443 \u043c\u0435\u043d\u044f. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 <a href=\"https:\/\/github.com\/lumberjackdev\/getting-started-spring-data-jdbc\/blob\/master\/src\/test\/java\/com\/lumberjackdev\/jdbcexample\/repository\/WarehouseRepositoryTest.java\"><u>\u0442\u0435\u0441\u0442\u044b<\/u><\/a> \u0441 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0435\u0439 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0441\u0432\u044f\u0437\u0438 &#171;\u043e\u0434\u0438\u043d-\u043a\u043e-\u043c\u043d\u043e\u0433\u0438\u043c&#187;. \u0413\u043b\u0430\u0432\u043d\u043e\u0435 \u0442\u043e, \u0447\u0442\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0438\u043b\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 <code>Warehouse<\/code> \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 <code>InventoryItem<\/code>.<\/p>\n<p>\u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 <code>InventoryItem<\/code> \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u043d\u0430\u0442\u044c \u043e <code>Warehouse<\/code>. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0443 \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0435\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 \u043f\u043e\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442 \u0435\u0433\u043e. \u0412 JPA \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0434\u0432\u0443\u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0435 \u0441\u0432\u044f\u0437\u0438, \u043d\u043e \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u0438\u043c \u0438 \u043f\u0440\u043e\u0432\u043e\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438, \u0435\u0441\u043b\u0438 \u0432\u044b \u0437\u0430\u0431\u0443\u0434\u0435\u0442\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u043e\u0431\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0441\u0432\u044f\u0437\u0438. Spring Data JDBC \u0441\u043f\u043e\u0441\u043e\u0431\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0432\u0430\u043c \u0441\u0432\u044f\u0437\u0435\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u0431\u0440\u0430\u0442\u043d\u0430\u044f \u0441\u0432\u044f\u0437\u044c &#171;\u043c\u043d\u043e\u0433\u0438\u0435-\u043a-\u043e\u0434\u043d\u043e\u043c\u0443&#187; \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f.<\/p>\n<h4>\u041c\u043d\u043e\u0433\u0438\u0435-\u043a-\u043e\u0434\u043d\u043e\u043c\u0443 \u0438 \u043c\u043d\u043e\u0433\u0438\u0435-\u043a\u043e-\u043c\u043d\u043e\u0433\u0438\u043c<\/h4>\n<p>\u0412 \u0440\u0430\u043c\u043a\u0430\u0445 \u044d\u0442\u043e\u0433\u043e \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0430 \u044f \u043d\u0435 \u0431\u0443\u0434\u0443 \u0432\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043e \u0441\u0432\u044f\u0437\u044f\u0445 &#171;\u043c\u043d\u043e\u0433\u0438\u0435-\u043a-\u043e\u0434\u043d\u043e\u043c\u0443&#187; \u0438\u043b\u0438 &#171;\u043c\u043d\u043e\u0433\u0438\u0435 \u043a\u043e \u043c\u043d\u043e\u0433\u0438\u043c&#187;. \u042f \u0441\u043e\u0432\u0435\u0442\u0443\u044e \u0438\u0437\u0431\u0435\u0433\u0430\u0442\u044c \u0441\u0432\u044f\u0437\u0435\u0439 &#171;\u043c\u043d\u043e\u0433\u0438\u0435-\u043a\u043e-\u043c\u043d\u043e\u0433\u0438\u043c&#187; \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043a\u0440\u0430\u0439\u043d\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435. \u0425\u043e\u0442\u044f \u0438\u043d\u043e\u0433\u0434\u0430 \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0438\u0437\u0431\u0435\u0436\u043d\u044b. \u041e\u0431\u0430 \u044d\u0442\u0438\u0445 \u0442\u0438\u043f\u0430 \u0441\u0432\u044f\u0437\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442\u0441\u044f \u0432 Spring Data JDBC \u0447\u0435\u0440\u0435\u0437 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 <code>Id<\/code> \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u043c\u0435\u0439\u0442\u0435 \u0432\u0432\u0438\u0434\u0443, \u0447\u0442\u043e \u0437\u0434\u0435\u0441\u044c \u0432\u0430\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u043e\u0438\u0442 \u0435\u0449\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0442\u0440\u0443\u0434\u0438\u0442\u044c\u0441\u044f.&nbsp;<\/p>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 Spring Data JPA, \u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0438\u0437 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u043b, \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0432\u0430\u043c \u0437\u043d\u0430\u043a\u043e\u043c\u0430. \u042f \u0443\u0436\u0435 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b \u0440\u0430\u043d\u0435\u0435, \u0447\u0442\u043e Spring Data JDBC \u0441\u0442\u0440\u0435\u043c\u0438\u0442\u0441\u044f \u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0449\u0435, \u0438 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043b\u0435\u043d\u0438\u0432\u0430\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430. \u041f\u043e\u043c\u0438\u043c\u043e \u044d\u0442\u043e\u0433\u043e, \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u0435 &#171;\u0433\u0440\u044f\u0437\u043d\u044b\u0445&#187; \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 (dirty tracking) \u0438 \u0441\u0435\u0441\u0441\u0438\u0438 (session). \u0415\u0441\u043b\u0438 \u0432 Spring Data JDBC \u0432\u044b \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442\u0435 \u043e\u0431\u044a\u0435\u043a\u0442, \u0442\u043e \u043e\u043d \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e (\u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0441\u0432\u044f\u0437\u0438) \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0435 \u0435\u0433\u043e \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439. \u041f\u0440\u0438\u043c\u0435\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u043f\u043e\u043a\u0430\u0437\u0430\u043b, \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0445\u043e\u0436\u0438 \u043d\u0430 \u0441\u0432\u043e\u0438 \u0430\u043d\u0430\u043b\u043e\u0433\u0438 \u0432 JPA, \u043d\u043e \u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e \u043c\u043d\u043e\u0433\u0438\u0435 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438 Spring Data JPA \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0432 Spring Data JDBC.<\/p>\n<p>\u0412 \u0446\u0435\u043b\u043e\u043c \u043c\u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f Spring Data JDBC. \u041f\u0440\u0438\u0437\u043d\u0430\u044e, \u0447\u0442\u043e \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435 \u043b\u0443\u0447\u0448\u0438\u0439 \u0432\u044b\u0431\u043e\u0440 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u043e\u0434\u043d\u0430\u043a\u043e \u044f \u0431\u044b \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043b \u0435\u0433\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c. \u041a\u0430\u043a \u0447\u0435\u043b\u043e\u0432\u0435\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u043f\u0440\u043e\u0448\u043b\u043e\u043c \u0431\u043e\u0440\u043e\u043b\u0441\u044f \u0441 \u043b\u0435\u043d\u0438\u0432\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439 \u0438 dirty tracking, \u044f \u0446\u0435\u043d\u044e \u0435\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0443. \u042f \u0434\u0443\u043c\u0430\u044e, \u0447\u0442\u043e \u044d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0432\u044b\u0431\u043e\u0440 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u044b\u0445 \u043e\u0431\u043b\u0430\u0441\u0442\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043d\u0435\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.<\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u043f\u043e\u043a\u0430 \u0432\u0441\u0435, \u0441\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0447\u0442\u0435\u043d\u0438\u0435! \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0432\u044b \u043d\u0430\u0448\u043b\u0438 \u044d\u0442\u043e \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c \u0438 \u043e\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Spring Data JDBC.<\/p>\n<hr>\n<blockquote>\n<p><a href=\"https:\/\/otus.pw\/FUU0\/\"><strong>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u043a\u0443\u0440\u0441\u0435<\/strong><\/a><strong> &#171;Java Developer. Professional&#187;. <\/strong><\/p>\n<p><strong><br \/><\/strong><a href=\"https:\/\/otus.pw\/z6ET\/\"><strong>\u0417\u0430\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u0443\u0440\u043e\u043a<\/strong><\/a><strong> &#171;\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 Spring Data jdbc&#187;<\/strong>. <\/p>\n<\/blockquote>\n<\/div>\n<p> \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\/company\/otus\/blog\/531332\/\"> https:\/\/habr.com\/ru\/company\/otus\/blog\/531332\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<blockquote>\n<p><strong>\u0414\u043b\u044f \u0431\u0443\u0434\u0443\u0449\u0438\u0445 \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u043e\u0432 \u043a\u0443\u0440\u0441\u0430 <\/strong><a href=\"https:\/\/otus.pw\/FUU0\/\"><strong>&#171;Java Developer. Professional&#187;<\/strong><\/a><strong> \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0433\u043e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u0435\u043c \u043f\u0440\u0438\u043d\u044f\u0442\u044c \u0443\u0447\u0430\u0441\u0442\u0438\u0435 \u0432 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u043c \u0443\u0440\u043e\u043a\u0435 \u043d\u0430 \u0442\u0435\u043c\u0443 <\/strong><a href=\"https:\/\/otus.pw\/z6ET\/\"><strong>&#171;\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 Spring Data jdbc&#187;<\/strong><\/a>  <\/p>\n<\/blockquote>\n<hr>\n<p>Spring Data JDBC \u0431\u044b\u043b <a href=\"https:\/\/spring.io\/blog\/2018\/09\/17\/introducing-spring-data-jdbc\"><u>\u0430\u043d\u043e\u043d\u0441\u0438\u0440\u043e\u0432\u0430\u043d<\/u><\/a> \u0432 2018 \u0433\u043e\u0434\u0443. \u0426\u0435\u043b\u044c\u044e \u0431\u044b\u043b\u043e \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0443 JPA, \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044f \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0430\u043c Spring Data. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0443\u0437\u043d\u0430\u0442\u044c \u043e \u043c\u043e\u0442\u0438\u0432\u0430\u0445, \u043b\u0435\u0436\u0430\u0449\u0438\u0445 \u0432 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432 <a href=\"https:\/\/docs.spring.io\/spring-data\/jdbc\/docs\/current\/reference\/html\/#jdbc.why\"><u>\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/u><\/a>.&nbsp;<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u043e\u043a\u0430\u0436\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Spring Data JDBC. \u0417\u0434\u0435\u0441\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0433\u043e \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0430, \u043d\u043e, \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0445\u0432\u0430\u0442\u0438\u0442, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e. \u041e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e, \u0435\u0441\u043b\u0438 \u0432\u044b \u0443\u0436\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0441\u043e Spring Data JPA. \u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 \u0432 <a href=\"https:\/\/github.com\/lumberjackdev\/getting-started-spring-data-jdbc\"><u>github<\/u><\/a>.<\/p>\n<p>\u0414\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u0441\u0442\u0430\u0440\u0442\u0430 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b <a href=\"https:\/\/github.com\/lumberjackdev\/spring-boot-java-11-postgres-template\"><u>\u044d\u0442\u043e\u0442 \u0448\u0430\u0431\u043b\u043e\u043d<\/u><\/a>.<\/p>\n<h4>\u041f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430<\/h4>\n<p>\u0418\u0437 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u044b <code>data-jdbc<\/code> \u2014 \u0441\u0442\u0430\u0440\u0442\u0435\u0440, <code>flyway<\/code> \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0445\u0435\u043c\u043e\u0439 \u0438 \u0434\u0440\u0430\u0439\u0432\u0435\u0440 <code>postgres<\/code> \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<pre><code class=\"javascript\">\/\/ build.gradle dependencies {     implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'      implementation 'org.flywaydb:flyway-core'      runtimeOnly 'org.postgresql:postgresql' }<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<pre><code class=\"kotlin\"># application.yml spring:   application:     name: template-app   datasource:     url: jdbc:postgresql:\/\/localhost:5432\/demo_app?currentSchema=app     username: app_user     password: change_me     driver-class-name: org.postgresql.Driver<\/code><\/pre>\n<h4>\u041c\u0430\u043f\u043f\u0438\u043d\u0433 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439<\/h4>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443:<\/p>\n<pre><code class=\"javascript\">create table book (     id varchar(32) not null,     title varchar(255) not null,     author varchar(255),     isbn varchar(15),     published_date date,     page_count integer,     primary key (id) );<\/code><\/pre>\n<p>\u0418 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 java-\u043a\u043b\u0430\u0441\u0441 (\u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e <code>@Id<\/code> \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0438\u0437 <code>org.springframework.data.annotation.Id<\/code>):<\/p>\n<pre><code class=\"javascript\">\/\/ Book.java public class Book {     @Id     private String id;     private String title;     private String author;     private String isbn;     private Instant publishedDate;     private Integer pageCount; }<\/code><\/pre>\n<p><em>\u041e\u0434\u043d\u0430\u043a\u043e, \u0435\u0441\u043b\u0438 \u043c\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c <\/em><a href=\"https:\/\/github.com\/lumberjackdev\/getting-started-spring-data-jdbc\/blob\/master\/src\/test\/java\/com\/lumberjackdev\/jdbcexample\/repository\/BookRepositoryTest.java\"><em><u>\u0442\u0435\u0441\u0442<\/u><\/em><\/a><em>:<\/em><\/p>\n<pre><code class=\"javascript\">\/\/ BookRepositoryTest.java @Test void canSaveBook() {     var book = Book.builder().author(\"Steven Erikson\").title(\"Gardens of the Moon\").build();     var savedBook = bookRepository.save(book);      assertThat(savedBook.getId()).isNotBlank();     assertThat(savedBook.getAuthor()).isEqualTo(book.getAuthor());     assertThat(savedBook.getTitle()).isEqualTo(book.getTitle());      assertThat(savedBook).isEqualTo(bookRepository.findById(savedBook.getId()).get()); }<\/code><\/pre>\n<p>\u0422\u043e \u0443\u0432\u0438\u0434\u0438\u043c \u043e\u0448\u0438\u0431\u043a\u0443 \u2014 ERROR: null value in column &#171;id&#187; violates not-null constraint. \u042d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u044b \u043d\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 \u043d\u0438 \u0441\u043f\u043e\u0441\u043e\u0431 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 id \u043d\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. \u041f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 Spring Data JDBC \u0432 \u0447\u0430\u0441\u0442\u0438 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u0432 <a href=\"https:\/\/docs.spring.io\/spring-data\/jdbc\/docs\/current\/reference\/html\/#jdbc.entity-persistence.id-generation\"><u>\u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f<\/u><\/a> \u043e\u0442 Spring Data JPA. \u0412 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c <code>ApplicationListener<\/code> \u0434\u043b\u044f <code>BeforeSaveEvent<\/code>:<\/p>\n<pre><code class=\"javascript\">\/\/ PersistenceConfig.java @Bean public ApplicationListener&lt;BeforeSaveEvent&gt; idGenerator() {     return event -&gt; {         var entity = event.getEntity();         if (entity instanceof Book) {             ((Book) entity).setId(UUID.randomUUID().toString());         }     }; }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0442\u0435\u0441\u0442 \u043f\u0440\u043e\u0439\u0434\u0435\u0442, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u043e\u043b\u0435 Id \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f. \u041f\u043e\u043b\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 \u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u0432 <a href=\"https:\/\/docs.spring.io\/spring-data\/jdbc\/docs\/current\/reference\/html\/#jdbc.events\"><u>\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/u><\/a>.<\/p>\n<h3>\u041c\u0435\u0442\u043e\u0434\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432&nbsp;<\/h3>\n<p>\u041e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 Spring Data \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f\u0445. Spring Data JDBC \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0437\u0434\u0435\u0441\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434. \u0414\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043c\u0435\u0442\u043e\u0434 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 <code>BookRepository<\/code>:<\/p>\n<pre><code class=\"javascript\">Optional&lt;Book&gt; findByTitle(String title);<\/code><\/pre>\n<p>\u0418 \u0435\u0441\u043b\u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0442\u0435\u0441\u0442:<\/p>\n<pre><code class=\"javascript\">@Test void canFindBookByTitle() {     var title = \"Gardens of the Moon\";     var book = Book.builder().author(\"Steven Erikson\").title(title).build();     var savedBook = bookRepository.save(book);     assertThat(bookRepository.findByTitle(title).get()).isEqualTo(savedBook); }<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u043c \u043e\u0448\u0438\u0431\u043a\u0443 \u2014 <code>Caused by: java.lang.IllegalStateException: No query specified on findByTitle<\/code>. \u0412 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f Spring Data JDBC <a href=\"https:\/\/docs.spring.io\/spring-data\/jdbc\/docs\/current\/reference\/html\/#jdbc.query-methods.at-query\"><u>\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442<\/u><\/a> \u0442\u043e\u043b\u044c\u043a\u043e \u044f\u0432\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u0437\u0430\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0435 \u0447\u0435\u0440\u0435\u0437 @Query. \u041d\u0430\u043f\u0438\u0448\u0435\u043c sql-\u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430:<\/p>\n<pre><code class=\"javascript\">@Query(\"select * from Book b where b.title = :title\") Optional&lt;Book&gt; findByTitle(@Param(\"title\") String title);<\/code><\/pre>\n<p>\u0422\u0435\u0441\u0442 \u043f\u0440\u043e\u0439\u0434\u0435\u043d! \u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0439\u0442\u0435 \u043e\u0431 \u044d\u0442\u043e\u043c \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u0432.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0447\u0438\u043a\u0430: \u0432 <a href=\"https:\/\/docs.spring.io\/spring-data\/jdbc\/docs\/current\/reference\/html\/#new-features.2-0-0\"><u>Spring Data JDBC 2.0<\/u><\/a> \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043f\u043e <a href=\"https:\/\/docs.spring.io\/spring-data\/jdbc\/docs\/current\/reference\/html\/#jdbc.query-methods\"><u>\u0438\u043c\u0435\u043d\u0430\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u0432<\/u><\/a>.&nbsp;<\/p>\n<h3>\u0421\u0432\u044f\u0437\u0438<\/h3>\n<p>\u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043e \u0441\u0432\u044f\u0437\u044f\u043c\u0438 Spring Data JDBC \u0442\u0430\u043a\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434. \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043b\u0435\u043d\u0438\u0432\u0430\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u0430 \u0441\u0432\u044f\u0437\u044c \u0432 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0439\u0442\u0435 \u0435\u0435 \u0442\u0443\u0434\u0430. \u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0430 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0439 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (Domain Driven Design), \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c, \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043a\u043e\u0440\u043d\u044f\u043c\u0438 \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u043e\u0432, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0434\u043e \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043a\u043e\u0440\u043d\u0438 \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u043e\u0432 \u0442\u044f\u043d\u0443\u043b\u0438 \u0437\u0430 \u0441\u043e\u0431\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0434\u0440\u0443\u0433\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432.<\/p>\n<h4>\u041e\u0434\u0438\u043d-\u043a-\u043e\u0434\u043d\u043e\u043c\u0443<\/h4>\n<p>\u0414\u043b\u044f \u0441\u0432\u044f\u0437\u0435\u0439 &#171;\u043e\u0434\u0438\u043d-\u043a-\u043e\u0434\u043d\u043e\u043c\u0443&#187; \u0438 &#171;\u043e\u0434\u0438\u043d-\u043a\u043e-\u043c\u043d\u043e\u0433\u0438\u043c&#187; \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f <code>@MappedCollection<\/code>. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 &#171;\u043e\u0434\u0438\u043d-\u043a-\u043e\u0434\u043d\u043e\u043c\u0443&#187;. \u041a\u043b\u0430\u0441\u0441&nbsp;<code>UserAccount<\/code> \u0431\u0443\u0434\u0435\u0442 \u0441\u0441\u044b\u043b\u0430\u0442\u044c\u0441\u044f \u043d\u0430 <code>Address<\/code>. \u0412\u043e\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 sql:<\/p>\n<pre><code class=\"sql\">create table address (     id      varchar(36) not null,     city    varchar(255),     state   varchar(255),     street  varchar(255),     zipcode varchar(255),     primary key (id) );  create table user_account (     id         varchar(36)  not null,     name       varchar(255) not null,     email      varchar(255) not null,     address_id varchar(36),     primary key (id),     constraint fk_user_account_address_id foreign key (address_id) references address (id) );<\/code><\/pre>\n<p>\u041a\u043b\u0430\u0441\u0441 <code>UserAccount<\/code> \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"sql\">\/\/ UserAccount.java public class UserAccount implements GeneratedId {     \/\/ ...other fields     @MappedCollection(idColumn = \"id\")     private Address address; }<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043e\u043f\u0443\u0449\u0435\u043d\u044b \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u043e\u043b\u044f, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043c\u0430\u043f\u043f\u0438\u043d\u0433 <code>address<\/code>. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 <code>idColumn<\/code> \u2014 \u044d\u0442\u043e \u0438\u043c\u044f \u043f\u043e\u043b\u044f \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 <code>Address<\/code>. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 <code>Address<\/code> \u043d\u0435\u0442 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043a\u043b\u0430\u0441\u0441 <code>UserAccount<\/code>, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <code>UserAccount<\/code>. \u042d\u0442\u043e \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0432 \u0442\u0435\u0441\u0442\u0435:<\/p>\n<pre><code class=\"sql\">\/\/UserAccountRepositoryTest.java @Test void canSaveUserWithAddress() {     var address = stubAddress();     var newUser = stubUser(address);      var savedUser = userAccountRepository.save(newUser);      assertThat(savedUser.getId()).isNotBlank();     assertThat(savedUser.getAddress().getId()).isNotBlank();      var foundUser = userAccountRepository.findById(savedUser.getId()).orElseThrow(IllegalStateException::new);     var foundAddress = addressRepository.findById(foundUser.getAddress().getId()).orElseThrow(IllegalStateException::new);      assertThat(foundUser).isEqualTo(savedUser);     assertThat(foundAddress).isEqualTo(savedUser.getAddress()); }<\/code><\/pre>\n<h4>\u041e\u0434\u0438\u043d-\u043a\u043e-\u043c\u043d\u043e\u0433\u0438\u043c<\/h4>\n<p>\u0412\u043e\u0442 sql, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0441\u0432\u044f\u0437\u0438 &#171;\u043e\u0434\u0438\u043d-\u043a\u043e-\u043c\u043d\u043e\u0433\u0438\u043c&#187;:<\/p>\n<pre><code class=\"sql\">create table warehouse (     id       varchar(36) not null,     location varchar(255),     primary key (id) );  create table inventory_item (     id        varchar(36) not null,     name      varchar(255),     count     integer,     warehouse varchar(36),     primary key (id),     constraint fk_inventory_item_warehouse_id foreign key (warehouse) references warehouse (id) );<\/code><\/pre>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0430 \u0441\u043a\u043b\u0430\u0434\u0435 (warehouse) \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0442\u043e\u0432\u0430\u0440\u043e\u0432\/\u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 (inventoryitems). \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 <code>Warehouse<\/code> \u043c\u044b \u0442\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>@MappedCollection<\/code> \u0434\u043b\u044f <code>InventoryItem<\/code>:<\/p>\n<pre><code class=\"sql\">public class Warehouse {     \/\/ ...other fields     @MappedCollection     Set&lt;InventoryItem&gt; inventoryItems = new HashSet&lt;&gt;();      public void addInventoryItem(InventoryItem inventoryItem) {         var itemWithId = inventoryItem.toBuilder().id(UUID.randomUUID().toString()).build();         this.inventoryItems.add(itemWithId);     } }  public class InventoryItem {     @Id     private String id;     private String name;     private int count; }<\/code><\/pre>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u044b \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043f\u043e\u043b\u0435 <code>id<\/code> \u0432\u043e \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0435 <code>addInventoryItem<\/code>. \u041c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c <code>ApplicationListener<\/code> \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0430 <code>Warehouse<\/code> \u0441 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 <code>BeforeSaveEvent<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043f\u043e\u043b\u0435 <code>id<\/code> \u0434\u043b\u044f \u0432\u0441\u0435\u0445 <code>InventoryItem<\/code>. \u0412\u0430\u043c \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0432 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u0442\u0430\u043a, \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0443 \u043c\u0435\u043d\u044f. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 <a href=\"https:\/\/github.com\/lumberjackdev\/getting-started-spring-data-jdbc\/blob\/master\/src\/test\/java\/com\/lumberjackdev\/jdbcexample\/repository\/WarehouseRepositoryTest.java\"><u>\u0442\u0435\u0441\u0442\u044b<\/u><\/a> \u0441 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0435\u0439 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0441\u0432\u044f\u0437\u0438 &#171;\u043e\u0434\u0438\u043d-\u043a\u043e-\u043c\u043d\u043e\u0433\u0438\u043c&#187;. \u0413\u043b\u0430\u0432\u043d\u043e\u0435 \u0442\u043e, \u0447\u0442\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0438\u043b\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 <code>Warehouse<\/code> \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 <code>InventoryItem<\/code>.<\/p>\n<p>\u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 <code>InventoryItem<\/code> \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u043d\u0430\u0442\u044c \u043e <code>Warehouse<\/code>. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0443 \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0435\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 \u043f\u043e\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442 \u0435\u0433\u043e. \u0412 JPA \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0434\u0432\u0443\u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0435 \u0441\u0432\u044f\u0437\u0438, \u043d\u043e \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u0438\u043c \u0438 \u043f\u0440\u043e\u0432\u043e\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438, \u0435\u0441\u043b\u0438 \u0432\u044b \u0437\u0430\u0431\u0443\u0434\u0435\u0442\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u043e\u0431\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0441\u0432\u044f\u0437\u0438. Spring Data JDBC \u0441\u043f\u043e\u0441\u043e\u0431\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0432\u0430\u043c \u0441\u0432\u044f\u0437\u0435\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u0431\u0440\u0430\u0442\u043d\u0430\u044f \u0441\u0432\u044f\u0437\u044c &#171;\u043c\u043d\u043e\u0433\u0438\u0435-\u043a-\u043e\u0434\u043d\u043e\u043c\u0443&#187; \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f.<\/p>\n<h4>\u041c\u043d\u043e\u0433\u0438\u0435-\u043a-\u043e\u0434\u043d\u043e\u043c\u0443 \u0438 \u043c\u043d\u043e\u0433\u0438\u0435-\u043a\u043e-\u043c\u043d\u043e\u0433\u0438\u043c<\/h4>\n<p>\u0412 \u0440\u0430\u043c\u043a\u0430\u0445 \u044d\u0442\u043e\u0433\u043e \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0430 \u044f \u043d\u0435 \u0431\u0443\u0434\u0443 \u0432\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043e \u0441\u0432\u044f\u0437\u044f\u0445 &#171;\u043c\u043d\u043e\u0433\u0438\u0435-\u043a-\u043e\u0434\u043d\u043e\u043c\u0443&#187; \u0438\u043b\u0438 &#171;\u043c\u043d\u043e\u0433\u0438\u0435 \u043a\u043e \u043c\u043d\u043e\u0433\u0438\u043c&#187;. \u042f \u0441\u043e\u0432\u0435\u0442\u0443\u044e \u0438\u0437\u0431\u0435\u0433\u0430\u0442\u044c \u0441\u0432\u044f\u0437\u0435\u0439 &#171;\u043c\u043d\u043e\u0433\u0438\u0435-\u043a\u043e-\u043c\u043d\u043e\u0433\u0438\u043c&#187; \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043a\u0440\u0430\u0439\u043d\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435. \u0425\u043e\u0442\u044f \u0438\u043d\u043e\u0433\u0434\u0430 \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0438\u0437\u0431\u0435\u0436\u043d\u044b. \u041e\u0431\u0430 \u044d\u0442\u0438\u0445 \u0442\u0438\u043f\u0430 \u0441\u0432\u044f\u0437\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442\u0441\u044f \u0432 Spring Data JDBC \u0447\u0435\u0440\u0435\u0437 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 <code>Id<\/code> \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u043c\u0435\u0439\u0442\u0435 \u0432\u0432\u0438\u0434\u0443, \u0447\u0442\u043e \u0437\u0434\u0435\u0441\u044c \u0432\u0430\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u043e\u0438\u0442 \u0435\u0449\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0442\u0440\u0443\u0434\u0438\u0442\u044c\u0441\u044f.&nbsp;<\/p>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 Spring Data JPA, \u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0438\u0437 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u043b, \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0432\u0430\u043c \u0437\u043d\u0430\u043a\u043e\u043c\u0430. \u042f \u0443\u0436\u0435 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b \u0440\u0430\u043d\u0435\u0435, \u0447\u0442\u043e Spring Data JDBC \u0441\u0442\u0440\u0435\u043c\u0438\u0442\u0441\u044f \u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0449\u0435, \u0438 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043b\u0435\u043d\u0438\u0432\u0430\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430. \u041f\u043e\u043c\u0438\u043c\u043e \u044d\u0442\u043e\u0433\u043e, \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u0435 &#171;\u0433\u0440\u044f\u0437\u043d\u044b\u0445&#187; \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 (dirty tracking) \u0438 \u0441\u0435\u0441\u0441\u0438\u0438 (session). \u0415\u0441\u043b\u0438 \u0432 Spring Data JDBC \u0432\u044b \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442\u0435 \u043e\u0431\u044a\u0435\u043a\u0442, \u0442\u043e \u043e\u043d \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e (\u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0441\u0432\u044f\u0437\u0438) \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0435 \u0435\u0433\u043e \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439. \u041f\u0440\u0438\u043c\u0435\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u043f\u043e\u043a\u0430\u0437\u0430\u043b, \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0445\u043e\u0436\u0438 \u043d\u0430 \u0441\u0432\u043e\u0438 \u0430\u043d\u0430\u043b\u043e\u0433\u0438 \u0432 JPA, \u043d\u043e \u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e \u043c\u043d\u043e\u0433\u0438\u0435 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438 Spring Data JPA \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0432 Spring Data JDBC.<\/p>\n<p>\u0412 \u0446\u0435\u043b\u043e\u043c \u043c\u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f Spring Data JDBC. \u041f\u0440\u0438\u0437\u043d\u0430\u044e, \u0447\u0442\u043e \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435 \u043b\u0443\u0447\u0448\u0438\u0439 \u0432\u044b\u0431\u043e\u0440 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u043e\u0434\u043d\u0430\u043a\u043e \u044f \u0431\u044b \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043b \u0435\u0433\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c. \u041a\u0430\u043a \u0447\u0435\u043b\u043e\u0432\u0435\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432<\/p>\n<\/hr>\n<\/blockquote>\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-314349","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/314349","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=314349"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/314349\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=314349"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=314349"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=314349"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}