{"id":299540,"date":"2020-03-02T09:00:31","date_gmt":"2020-03-02T09:00:31","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=299540"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=299540","title":{"rendered":"JOOQ \u0438 \u0435\u0433\u043e \u043a\u0440\u043e\u043b\u0438\u0447\u044c\u044f \u043d\u043e\u0440\u0430. \u041a\u0430\u043a \u0432\u044b\u0436\u0438\u0442\u044c \u0431\u0435\u0437 Hibernate"},"content":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/488522\/\">\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043d\u0435 \u0431\u0443\u0434\u0443 \u0442\u043e\u043f\u0438\u0442\u044c \u0437\u0430 JOOQ. \u042f \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u044e Hibernate \u0438 \u0432\u0441\u044e \u0441\u0438\u043b\u0443 Spring Data JPA, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0437\u0430 \u043d\u0438\u043c \u0441\u0442\u043e\u0438\u0442. \u041d\u043e \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u043e \u043d\u0438\u0445.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/wt\/-0\/co\/wt-0condklmkd6zkb2ag_a46vb4.png\"><\/p>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f Hibernate \u0438 Spring Data JPA, \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0434\u0443\u043c\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u0445 \u2014 \u0437\u043d\u0430\u0439 \u0441\u0442\u0430\u0432\u044c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0438 \u043f\u0438\u0448\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0435 \u0438\u043c\u0435\u043d\u0430 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u2014 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u0430 \u0442\u0435\u0431\u044f \u0441\u0434\u0435\u043b\u0430\u044e\u0442 \u044d\u0442\u0438 \u0434\u0432\u0430 \u043c\u043e\u043d\u0441\u0442\u0440\u0430. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0432 JOOQ, \u043a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e \u0434\u043b\u044f \u043c\u043d\u043e\u0433\u0438\u0445, \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043c\u0430\u043b\u043e\u0441\u0442\u044c \u043d\u0430\u043f\u0440\u044f\u0447\u044c\u0441\u044f \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c <i>findAllByUserId(Long userId)<\/i>.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h2>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 JOOQ?<\/h2>\n<p>  \u041d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 SQL-\u0437\u0430\u043f\u0440\u043e\u0441:<\/p>\n<pre><code class=\"sql\">select * from countries c where c.population &gt; 10000000;<\/code><\/pre>\n<p>  \u042d\u0442\u043e \u0437\u0430\u043f\u0440\u043e\u0441 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438. \u041e\u043a\u0435\u0439.<\/p>\n<p>  \u041d\u0430\u043c \u043d\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438. \u041d\u0430\u043c \u0445\u043e\u0447\u0435\u0442\u0441\u044f, \u0447\u0442\u043e\u0431\u044b \u044d\u0442\u043e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u043b\u043e \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e \u0431\u044b\u043b \u043d\u0435 \u043e\u0434\u043d\u043e\u0440\u0430\u0437\u043e\u0432\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u0438 \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0432\u0430\u043b\u0438\u0434\u0438\u0440\u043e\u0432\u0430\u043b\u0441\u044f \u0445\u043e\u0442\u044f \u0431\u044b \u043d\u0430 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441. \u0414\u0435\u043b\u0430\u0435\u043c \u044d\u0442\u043e \u0447\u0435\u0440\u0435\u0437 Spring Data JPA:<\/p>\n<pre><code class=\"java\">List&lt;Country&gt; findAllByPopulationAfter(Long amount);<\/code><\/pre>\n<p>  \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0442\u043e\u0442 \u0436\u0435 \u0441\u0430\u043c\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441, \u0447\u0442\u043e \u0438 \u0432\u044b\u0448\u0435, \u043d\u043e \u0441\u0438\u043b\u0430\u043c\u0438 Spring.<\/p>\n<p>  \u041a\u0430\u043a\u0438\u0435 \u044f\u0432\u043d\u044b\u0435 \u043f\u043b\u044e\u0441\u044b \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430? \u0415\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043c\u043e\u0449\u043d\u044b\u0439 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a, \u043e\u043d \u0436\u0435 \u0432\u0430\u043b\u0438\u0434\u0438\u0440\u0443\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043e\u0448\u0438\u0431\u043e\u043a. \u041d\u043e \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438 \u0431\u0435\u0440\u0451\u0442 \u043d\u0430 \u0441\u0435\u0431\u044f \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a. \u0410 \u043d\u0430\u043c \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c, \u043d\u043e \u0432 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0440\u043e\u0441 \u0431\u044b\u043b \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043e\u0442\u0432\u0430\u043b\u0438\u0434\u0438\u0440\u043e\u0432\u0430\u043d.<br \/>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <i><a href=\"https:\/\/habr.com\/ru\/users\/query\/\" class=\"user_link\">Query<\/a><\/i>:<\/p>\n<pre><code class=\"java\">@Query(&quot;select c from Country c where c.population &gt; :amount&quot;) List&lt;Country&gt; findAllPopulationGreaterThan(@Param(&quot;amount&quot;) Long amount);<\/code><\/pre>\n<p>  \u0413\u043e\u0434\u0438\u0442\u0441\u044f \u0438 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u043c\u043f\u0440\u043e\u043c\u0438\u0441\u0441 \u043c\u0435\u0436\u0434\u0443 SQL \u0438 DSL. \u041d\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u043d\u0435 \u0445\u043e\u0442\u0438\u043c \u043c\u0430\u0440\u0430\u0442\u044c\u0441\u044f \u043e\u0431 SQL, \u043d\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u044f\u0442\u043d\u043e \u0432\u0438\u0434\u0435\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435:<\/p>\n<pre><code class=\"java\">return dsl.selectFrom(COUNTRIES)                 .where(COUNTRIES.POPULATION.greaterThan(amount))                 .fetch();<\/code><\/pre>\n<p>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0434\u043e\u0439\u0434\u0443\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a:<\/p>\n<p>  <i>QueryDSL<br \/>  JOOQ<br \/>  Speedment<\/i><\/p>\n<p>  \u041f\u0440\u043e QueryDSL \u044f <a href=\"https:\/\/habr.com\/ru\/post\/344450\/\"><u>\u043f\u0438\u0441\u0430\u043b<\/u><\/a> \u043f\u0430\u0440\u0443 \u043b\u0435\u0442 \u043d\u0430\u0437\u0430\u0434. Speedment \u044f \u043d\u0435 \u043a\u043e\u043f\u0430\u043b, \u043d\u043e \u044d\u0442\u043e, \u043f\u043e\u0445\u043e\u0436\u0435, \u0443\u0436\u0435 \u043d\u0435\u0447\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0435\u0435, \u0447\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 DSL-\u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440, \u043f\u043b\u044e\u0441 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043f\u043e\u0434\u0443\u0447\u0438\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043e\u043d\u0438 \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043b\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u0412 \u043e\u0431\u0449\u0435\u043c, \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e JOOQ.<\/p>\n<h2>\u0417\u0430\u043f\u0440\u043e\u0441\u044b JOOQ<\/h2>\n<p>  \u0414\u0430, \u043e\u0434\u0438\u043d \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043c\u044b \u0443\u0436\u0435 \u0432\u0438\u0434\u0435\u043b\u0438 \u0432\u044b\u0448\u0435:<\/p>\n<pre><code class=\"java\">return dsl.selectFrom(COUNTRIES)                 .where(COUNTRIES.POPULATION.greaterThan(amount))                 .fetch();<\/code><\/pre>\n<p>  \u041a\u0430\u043a\u0438\u0435 \u0431\u044b\u0432\u0430\u044e\u0442 \u0435\u0449\u0451?<\/p>\n<p>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u043e\u0441\u0442\u043e\u0439 get-\u0437\u0430\u043f\u0440\u043e\u0441:<\/p>\n<pre><code class=\"java\">return dsl.selectFrom(Countries.COUNTRIES)                 .where(Countries.COUNTRIES.ID.eq(id))                 .fetchAny();<\/code><\/pre>\n<p>  \u0418\u043b\u0438 insert-\u0437\u0430\u043f\u0440\u043e\u0441:<\/p>\n<pre><code class=\"java\">return dsl.insertInto(Countries.COUNTRIES)                 .set(Countries.COUNTRIES.NAME, country.getName())                 .set(Countries.COUNTRIES.POPULATION, country.getPopulation())                 .set(Countries.COUNTRIES.GOVERNMENT_FORM, nameOrNull(country.getGovernmentForm()))                 .returning()                 .fetchOne();<\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u0432\u0441\u0451 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043d\u0438\u0447\u0435\u0433\u043e \u043b\u0438\u0448\u043d\u0435\u0433\u043e. \u041d\u043e \u044d\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434. \u0412\u044b\u044f\u0441\u043d\u0435\u043d\u0438\u0435, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0433\u043b\u0443\u0431\u043e\u043a\u0430 \u044d\u0442\u0430 \u043a\u0440\u043e\u043b\u0438\u0447\u044c\u044f \u043d\u043e\u0440\u0430, \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043d\u044f\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0434\u0435\u043b\u044c.<\/p>\n<p>  \u041d\u043e \u043d\u0430\u0447\u043d\u0451\u043c \u0441 \u043d\u0430\u0447\u0430\u043b\u0430.<\/p>\n<h2>\u0414\u0430, \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 Maven<\/h2>\n<p>  \u042f \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u044e Gradle. \u041d\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 JOOQ \u043f\u043e\u0447\u0435\u043c\u0443-\u0442\u043e \u0443\u0434\u0435\u043b\u044f\u044e\u0442 Gradle \u043c\u0435\u043d\u044c\u0448\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f, \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044f \u0438\u0434\u0442\u0438 \u0437\u0430 \u043f\u043b\u0430\u0433\u0438\u043d\u0430\u043c\u0438 \u043a \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c. \u041e\u043a\u0435\u0439, \u0443\u0447\u0435\u0431\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430 Maven. \u041d\u043e \u0435\u0441\u043b\u0438 \u0442\u044b, \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u044b\u0439 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044c, \u043f\u043e\u043a\u043e\u043f\u0430\u043b\u0441\u044f \u043a\u0430\u043a \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0432 \u0433\u043b\u0443\u0431\u0438\u043d\u0430\u0445 \u0433\u0438\u0442\u0445\u0430\u0431\u0430 \u0438 \u0433\u043e\u0442\u043e\u0432 \u044f\u0432\u0438\u0442\u044c \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u043d\u0430 Gradle \u2014 \u043f\u0438\u0448\u0438 \u043c\u043d\u0435, \u0438 \u0442\u044b \u0441\u0442\u0430\u043d\u0435\u0448\u044c \u0441\u043e\u0430\u0432\u0442\u043e\u0440\u043e\u043c \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438. \u042d\u0442\u043e \u0436\u0435 \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u0438 H2 (\u0443\u0447\u0435\u0431\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430 PostgreSQL).<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u0447\u0435\u043c\u0443 \u0443 \u043c\u0435\u043d\u044f \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0441 Gradle \u0438 H2<\/b><\/p>\n<div class=\"spoiler_text\">\u042f \u043f\u043e\u043b\u0434\u043d\u044f \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u043b \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u0432\u0435\u0441\u0442\u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u0447\u0435\u0440\u0435\u0437 Gradle. \u0418 \u043f\u043e\u0441\u043b\u0435 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u043d\u0435\u0443\u0434\u0430\u0447\u043d\u043e\u0439 \u043f\u043e\u043f\u044b\u0442\u043a\u0438 \u044f \u0440\u0435\u0448\u0438\u043b \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043b\u0430\u0432\u0440\u044b \u0443\u043a\u0440\u043e\u0442\u0438\u0442\u0435\u043b\u044f jooq-generator \u043f\u043e\u0442\u043e\u043c\u043a\u0430\u043c. \u0412\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043b\u0434\u043d\u044f \u044f \u043f\u044b\u0442\u0430\u043b\u0441\u044f \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0441 \u0431\u0430\u0437\u044b \u043d\u0430 H2, \u043d\u043e \u00ab\u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0430\u044f \u043f\u043e\u0431\u0435\u0434\u043e\u043d\u043e\u0441\u043d\u0430\u044f \u0432\u043e\u0439\u043d\u0430\u00bb \u0441\u043e \u0441\u0445\u0435\u043c\u0430\u043c\u0438 H2 \u0432\u0441\u0451 \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0438\u0434\u0435\u043b\u0430\u0441\u044c \u043d\u0435 \u0442\u0430\u043a\u043e\u0439 \u0443\u0436 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0439 \u0438 \u043f\u043e\u0431\u0435\u0434\u043e\u043d\u043e\u0441\u043d\u043e\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044d\u0442\u0438 \u043b\u0430\u0432\u0440\u044b, \u0434\u043e\u0440\u043e\u0433\u043e\u0439 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044c, \u0442\u0430\u043a \u0436\u0435 \u043c\u043e\u0433\u0443\u0442 \u0441\u0442\u0430\u0442\u044c \u0442\u0432\u043e\u0438\u043c\u0438.  <\/div>\n<\/div>\n<p>  \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 Maven:<\/p>\n<pre><code class=\"xml\">&lt;dependencies&gt;          &lt;!-- Spring Starters --&gt;         &lt;dependency&gt;             &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;             &lt;artifactId&gt;spring-boot-starter-jooq&lt;\/artifactId&gt;         &lt;\/dependency&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.flywaydb&lt;\/groupId&gt;             &lt;artifactId&gt;flyway-core&lt;\/artifactId&gt;         &lt;\/dependency&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;!-- Helpers --&gt;         &lt;dependency&gt;             &lt;groupId&gt;org.apache.commons&lt;\/groupId&gt;             &lt;artifactId&gt;commons-lang3&lt;\/artifactId&gt;             &lt;version&gt;${commons.lang3.version}&lt;\/version&gt;         &lt;\/dependency&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;!--Test --&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;exclusions&gt;                 &lt;exclusion&gt;                     &lt;groupId&gt;org.junit.vintage&lt;\/groupId&gt;                     &lt;artifactId&gt;junit-vintage-engine&lt;\/artifactId&gt;                 &lt;\/exclusion&gt;             &lt;\/exclusions&gt;         &lt;\/dependency&gt;          &lt;!-- JOOQ Generator --&gt;         &lt;dependency&gt;             &lt;groupId&gt;org.jooq&lt;\/groupId&gt;             &lt;artifactId&gt;jooq&lt;\/artifactId&gt;             &lt;version&gt;${jooq.version}&lt;\/version&gt;         &lt;\/dependency&gt;         &lt;dependency&gt;             &lt;groupId&gt;org.jooq&lt;\/groupId&gt;             &lt;artifactId&gt;jooq-meta&lt;\/artifactId&gt;             &lt;version&gt;${jooq.version}&lt;\/version&gt;         &lt;\/dependency&gt;         &lt;dependency&gt;             &lt;groupId&gt;org.jooq&lt;\/groupId&gt;             &lt;artifactId&gt;jooq-codegen&lt;\/artifactId&gt;             &lt;version&gt;${jooq.version}&lt;\/version&gt;         &lt;\/dependency&gt;      &lt;\/dependencies&gt;<\/code><\/pre>\n<p>  \u0423 Spring \u0443\u0436\u0435 \u0435\u0441\u0442\u044c JOOQ \u0441\u0442\u0430\u0440\u0442\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0430\u043c\u043e\u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442 DataSource \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c\u0438 \u0438\u0437 application.yml. \u041d\u043e \u0434\u043b\u044f \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b JOOQ \u044d\u0442\u043e\u0433\u043e \u043c\u0430\u043b\u043e. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438. \u0414\u0430-\u0434\u0430, \u043c\u044b \u043d\u0435 \u043f\u0438\u0448\u0435\u043c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u0430 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u0438\u0445. \u0422\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 table-first.<\/p>\n<p>  \u041e\u0431\u044b\u0447\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 \u0444\u043e\u043a\u0443\u0441\u0435 \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/c-\/pz\/tp\/c-pztpdxbkn5kxot-s_08tzlzbk.jpeg\"><\/p>\n<p>  \u0414\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u043f\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e \u0432 \u0432\u0438\u0434\u0435 \u043f\u043b\u043e\u0441\u043a\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 (DTO). \u0414\u0430\u043b\u0435\u0435, \u043a\u043e\u0433\u0434\u0430 \u0441\u0435\u0440\u0432\u0438\u0441\u0443 \u043d\u0430\u0434\u043e \u043f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0431\u0430\u0437\u043e\u0439, \u043e\u043d \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 DTO \u0432 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c, \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439, \u0430 \u0442\u043e\u0442 \u0443\u0436\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0435\u0451 \u0432 \u0431\u0430\u0437\u0443. \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 JOOQ \u0432\u0438\u0434\u044f\u0442 \u0432\u0441\u0451 \u0438\u043d\u0430\u0447\u0435:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/vv\/wy\/4b\/vvwy4bbp1ox57f4j0edmulfe7ni.jpeg\"><\/p>\n<p>  \u041a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0432 JOOQ \u0432\u0441\u0435\u0440\u044c\u0451\u0437 \u043f\u0435\u0440\u0435\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0438 \u0440\u0435\u0448\u0438\u043b\u0438 \u0438\u0434\u0442\u0438 \u0441\u0432\u043e\u0438\u043c \u043f\u0443\u0442\u0451\u043c. \u041e\u0442\u043b\u0438\u0447\u0438\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b:<\/p>\n<ol>\n<li>\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 DTO \u0432 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0443\u0436\u0435 \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438. <\/li>\n<li>\u0421\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u043a\u0430\u043a \u0442\u0430\u043a\u043e\u0432\u0443\u044e \u043c\u044b \u043d\u0435 \u043f\u0438\u0448\u0435\u043c. \u0415\u0451 \u043f\u0438\u0448\u0435\u0442 \u0437\u0430 \u043d\u0430\u0441 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 JOOQ. <\/li>\n<\/ol>\n<p>  \u0423\u0436\u0435 \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434\u044b, \u0447\u0442\u043e JOOQ \u043d\u0435 \u0442\u0430\u043a \u043f\u0440\u043e\u0441\u0442. \u0421\u043b\u043e\u0436\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c\u0430\u044f \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u0430\u044f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c, \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 \u043c\u0430\u043f\u043f\u0438\u043d\u0433 \u0432 DTO \u0438 \u043f\u0440\u043e\u0447\u0438\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043e\u0442\u043f\u0443\u0433\u043d\u0443\u0442 \u043c\u043d\u043e\u0433\u0438\u0445. \u041d\u043e \u0432 \u0442\u0435\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445, \u043a\u043e\u0433\u0434\u0430 \u0434\u0435\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0435\u043a\u0443\u0434\u0430, \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0435 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435 \u044d\u0442\u0438\u0445 \u0430\u0441\u043f\u0435\u043a\u0442\u043e\u0432 JOOQ \u043c\u043e\u0436\u0435\u0442 \u0441\u0435\u0440\u044c\u0451\u0437\u043d\u043e \u0443\u0432\u043b\u0435\u0447\u044c \u0438 \u0437\u0430\u043d\u044f\u0442\u044c \u0434\u043d\u0438, \u0430 \u0442\u043e \u0438 \u043d\u0435\u0434\u0435\u043b\u0438. \u0423\u0432\u0435\u0440\u0435\u043d, \u043c\u043e\u0439 \u043f\u043e\u0441\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442 \u0412\u0430\u0448\u0435 \u0432\u0440\u0435\u043c\u044f.<\/p>\n<p>  \u041c\u044b \u0437\u0430\u0442\u0440\u043e\u043d\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0430\u0441\u043f\u0435\u043a\u0442\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0441 JOOQ:<\/p>\n<ul>\n<li>\u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439. <\/li>\n<li>\u041d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 CRUD. <\/li>\n<li>\u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 CRUD. <\/li>\n<li>\u0418 \u0435\u0449\u0451 \u043e\u0434\u043d\u0430 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 CRUD. <\/li>\n<li>\u041c\u0430\u043f\u0438\u043d\u0433 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u0441\u0438\u043b\u0430\u043c\u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 JOOQ. <\/li>\n<li>\u0438 \u043f\u043e\u0440\u0430\u0441\u0441\u0443\u0436\u0434\u0430\u0435\u043c \u043e \u0442\u043e\u043c, \u0437\u0430\u0447\u0435\u043c \u0432\u0441\u0451 \u044d\u0442\u043e \u043d\u0430\u0434\u043e. <\/li>\n<\/ul>\n<p>  \u041d\u0443, \u043f\u043e\u0435\u0445\u0430\u043b\u0438.<\/p>\n<h2>\u0427\u0442\u043e \u043c\u044b \u043d\u0430\u043f\u0438\u0448\u0435\u043c?<\/h2>\n<p>  \u041d\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0434\u0432\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438:<\/p>\n<p>  Country:<\/p>\n<pre><code class=\"java\">@Data public class Country {      private Long id;     private String name;     private GovernmentForm governmentForm;     private Integer population;      private List&lt;City&gt; cities; }<\/code><\/pre>\n<p>  City:<\/p>\n<pre><code class=\"java\">@Data public class City {      private Long id;     private Long countryId;     private String name; }<\/code><\/pre>\n<p>  \u0421\u0432\u044f\u0437\u044c \u043e\u0434\u0438\u043d-\u043a\u043e-\u043c\u043d\u043e\u0433\u0438\u043c. Country \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 City. City \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 countryId.<br \/>  Flyway-\u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"sql\">create table countries (     id              bigserial primary key,     name            varchar(255),     government_form varchar(255),     population      int );  create table cities (     id         bigserial primary key,     country_id bigint,     name       varchar(255) );<\/code><\/pre>\n<p>  <\/p>\n<h2>\u041d\u0430\u0447\u043d\u0451\u043c \u0441 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439<\/h2>\n<p>  \u0421\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u043a\u0430\u043a \u044f \u0443\u0436\u0435 \u0441\u043a\u0430\u0437\u0430\u043b, \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e. \u0415\u0441\u0442\u044c \u0434\u0432\u0430 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c.<\/p>\n<ul>\n<li>\u041f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u043f\u043b\u0430\u0433\u0438\u043d\u0430 Maven. <\/li>\n<li>\u0412 Java-\u043a\u043e\u0434\u0435. <\/li>\n<\/ul>\n<p>  <\/p>\n<h2>\u0413\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0432 Maven<\/h2>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441\u0431\u043e\u0440\u043a\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, Maven \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438. \u0410 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0432 \u043b\u044e\u0431\u043e\u0439 \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438. \u042d\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0432 \u0442\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b, \u043a\u043e\u0433\u0434\u0430, \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043f\u043e\u043c\u0435\u043d\u044f\u043b\u0430\u0441\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0431\u0430\u0437\u044b. \u041f\u043b\u0430\u0433\u0438\u043d \u0432 Maven \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"xml\">            &lt;!-- JOOQ Generator Plugin --&gt;             &lt;plugin&gt;                 &lt;groupId&gt;org.jooq&lt;\/groupId&gt;                 &lt;artifactId&gt;jooq-codegen-maven&lt;\/artifactId&gt;                 &lt;version&gt;${jooq.version}&lt;\/version&gt;                 &lt;executions&gt;                     &lt;execution&gt;                         &lt;phase&gt;generate-sources&lt;\/phase&gt;                         &lt;goals&gt;                             &lt;goal&gt;generate&lt;\/goal&gt;                         &lt;\/goals&gt;                     &lt;\/execution&gt;                 &lt;\/executions&gt;                 &lt;configuration&gt;                     &lt;jdbc&gt;  &lt;!-- \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0431\u0430\u0437\u044b --&gt;                         &lt;driver&gt;${db.driver}&lt;\/driver&gt;                         &lt;url&gt;${db.url}&lt;\/url&gt;                         &lt;user&gt;${db.username}&lt;\/user&gt;                         &lt;password&gt;${db.password}&lt;\/password&gt;                     &lt;\/jdbc&gt;                     &lt;generator&gt;                         &lt;database&gt;                             &lt;includes&gt;.*&lt;\/includes&gt;  &lt;!-- \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u044b\u0435 \u043f\u043e\u0434\u043f\u0430\u043a\u0435\u0442\u044b \u0438 \u0444\u0430\u0439\u043b\u044b --&gt;                             &lt;excludes&gt;  &lt;!-- \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u044b\u0435 \u043f\u043e\u0434\u043f\u0430\u043a\u0435\u0442\u044b \u0438 \u0444\u0430\u0439\u043b\u044b --&gt;                                 flyway_schema_history                             &lt;\/excludes&gt;                             &lt;inputSchema&gt;public&lt;\/inputSchema&gt;  &lt;!-- \u0441\u0445\u0435\u043c\u0430 --&gt;                         &lt;\/database&gt;                         &lt;generate&gt;                             &lt;records&gt;true&lt;\/records&gt;                         &lt;\/generate&gt;                         &lt;target&gt;                             &lt;!-- \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 --&gt;                             &lt;packageName&gt;ru.xpendence.jooqexample.domain&lt;\/packageName&gt;                             &lt;!-- \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f. \u041b\u0443\u0447\u0448\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 target. --&gt;                             &lt;directory&gt;target\/generated-sources\/jooq&lt;\/directory&gt;                         &lt;\/target&gt;                     &lt;\/generator&gt;                 &lt;\/configuration&gt;             &lt;\/plugin&gt;<\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0432\u0441\u0451 \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u0435 Maven \u0438 \u0441\u0440\u0435\u0434\u0438 \u043f\u043b\u0430\u0433\u0438\u043d\u043e\u0432 \u0443\u0432\u0438\u0434\u0438\u0442\u0435 jooq-codegen. <\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/1n\/ch\/pv\/1nchpvafnxml7qle_dfsq1zsuje.png\"><\/p>\n<p>  \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0435\u0433\u043e. \u041e\u043d \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0432\u0430\u043c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/cs\/kf\/la\/cskfla2pzxfkm-vkot_dcggqoia.png\"><\/p>\n<p>  \u042d\u0442\u043e \u0442\u0435 \u0441\u0430\u043c\u044b\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0412\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0431\u0430\u0437\u0435. \u041f\u0435\u0440\u0432\u0430\u044f \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u043e\u0441\u0442\u044c: \u043e\u043d\u0438 \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b. \u0422\u043e \u0435\u0441\u0442\u044c, \u043e\u043d\u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b, \u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u043e\u0432 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0442\u0430\u043a\u0438\u043c \u0445\u0438\u0442\u0440\u043e\u0432\u044b\u0434\u0443\u043c\u0430\u043d\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c, \u0447\u0442\u043e \u044d\u0442\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043f\u043e\u0442\u044f\u043d\u0435\u0442 \u043d\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u0439\u0442\u0435\u0441\u044c \u043f\u0440\u043e\u0434\u0443\u043c\u0430\u0442\u044c \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446.<\/p>\n<p>  \u0421\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0441\u0432\u043e\u0435\u043e\u0431\u0440\u0430\u0437\u043d\u043e. \u0412\u043e\u0442, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 CountriesRecord:<\/p>\n<pre><code class=\"java\">public class CountriesRecord extends UpdatableRecordImpl&lt;CountriesRecord&gt; implements Record4&lt;Long, String, String, Integer&gt; {     \/\/...<\/code><\/pre>\n<p>  \u041a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c, CountriesRecord \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0438\u0442 Record4, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f 4-\u043c\u044f \u0442\u0438\u043f\u0430\u043c\u0438. \u0412 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 countries 4 \u043a\u043e\u043b\u043e\u043d\u043a\u0438, \u043f\u043e\u0442\u043e\u043c\u0443 \u0438 Record4. \u0412\u043e\u0442 \u0432 cities 3 \u043a\u043e\u043b\u043e\u043d\u043a\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 Record3. \u0417\u0430\u0447\u0435\u043c \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043d\u043e, \u044f \u043d\u0435 \u0437\u043d\u0430\u044e. \u0412\u0441\u0435\u0433\u043e \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 JOOQ 22 \u0442\u0430\u043a\u0438\u0445 \u0440\u0435\u043a\u043e\u0440\u0434\u0430, Record1&#8230;Record22. \u0418\u0437 \u0447\u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434, \u0447\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 JOOQ \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u044b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446 \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u043e\u043c \u0432 22 \u043a\u043e\u043b\u043e\u043d\u043a\u0438, \u043d\u043e \u044d\u0442\u043e \u043d\u0435 \u0442\u0430\u043a. \u0423 \u043c\u0435\u043d\u044f \u0435\u0441\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u0435\u0441\u044f\u0442\u043a\u043e\u0432 \u043a\u043e\u043b\u043e\u043d\u043e\u043a, \u0438 JOOQ \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0440\u0430\u0437\u0443 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0438\u0442 \u043e\u0442 Record. \u041d\u0443, \u0442\u0430\u043a\u043e\u0435\u2026<\/p>\n<p>  \u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 JOOQ \u0432 Java-\u043a\u043e\u0434\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"java\">@Component public class AfterStartupApplicationListener implements ApplicationListener&lt;ContextRefreshedEvent&gt; {      @Value(&quot;${spring.datasource.driver-class-name}&quot;)     private String driver;      @Value(&quot;${spring.datasource.url}&quot;)     private String url;      @Value(&quot;${spring.datasource.username}&quot;)     private String username;      @Value(&quot;${spring.datasource.password}&quot;)     private String password;      @Value(&quot;${jooq.generator.database.name}&quot;)     private String databaseName;      @Value(&quot;${jooq.generator.database.with-includes}&quot;)     private String databaseWithIncludes;      @Value(&quot;${jooq.generator.database.with-input-schema}&quot;)     private String databaseWithInputSchema;      @Value(&quot;${jooq.generator.target.package-name}&quot;)     private String targetPackageName;      @Value(&quot;${jooq.generator.target.directory}&quot;)     private String targetDirectory;      @SneakyThrows     @Override     public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {         new GenerationTool().run(configureGenerator());     }      private Configuration configureGenerator() {         return new Configuration()                 .withJdbc(new Jdbc()                         .withDriver(driver)                         .withUrl(url)                         .withUser(username)                         .withPassword(password))                 .withGenerator(new Generator()                         .withDatabase(new Database()                                 .withName(databaseName)                                 .withIncludes(databaseWithIncludes)                                 .withExcludes(&quot;&quot;)                                 .withInputSchema(databaseWithInputSchema))                         .withTarget(new Target()                                 .withPackageName(targetPackageName)                                 .withDirectory(targetDirectory)));     } }<\/code><\/pre>\n<p>  \u0412 \u043c\u043e\u0451\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u043b\u043d\u043e\u0433\u043e \u0441\u0442\u0430\u0440\u0442\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u043a\u0430\u0442\u0438\u043b\u0438\u0441\u044c \u0432\u0441\u0435 \u043d\u043e\u0432\u044b\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0438 \u0431\u0430\u0437\u0430 \u0432 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438.<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u0438, \u0438\u043c\u0435\u0435\u043c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u0438\u043c\u0435\u0435\u043c \u0431\u0430\u0437\u0443. \u041f\u043e\u0440\u0430 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0438 \u043f\u0438\u0441\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b.<\/p>\n<h2>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f<\/h2>\n<p>  \u0412\u0441\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0445\u043e\u0434\u044f\u0442 \u0447\u0435\u0440\u0435\u0437 DslContext. \u0417\u0430\u0430\u0432\u0442\u043e\u0432\u0430\u0439\u0440\u0438\u043c DslContext.<\/p>\n<pre><code class=\"java\">@Repository @RequiredArgsConstructor public class CountryRepository implements CrudRepository&lt;Country&gt; {      private final DSLContext dsl;  } <\/code><\/pre>\n<p>  \u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0433\u043e\u0442\u043e\u0432.<\/p>\n<h2>\u041d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 CRUD<\/h2>\n<p>  <\/p>\n<h3>Insert<\/h3>\n<p>  \u0415\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c SQL, \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0435\u0449\u0451 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u044b \u0431\u044b\u043b \u0431\u044b \u0442\u0430\u043a\u0438\u043c:<\/p>\n<pre><code class=\"sql\">insert into countries(name, government_form, population) values ('\u0413\u0430\u0431\u043e\u043d \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c', 'UNITARY', 100500) returning *;<\/code><\/pre>\n<p>  \u0412 JOOQ \u0437\u0430\u043f\u0440\u043e\u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d \u043a \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0443 SQL:<\/p>\n<pre><code class=\"java\">    public Country insertValues(Country country) {         return dsl.insertInto(Countries.COUNTRIES)  \/\/insert into countries                 .values(country.getId(), country.getName(), country.getPopulation(), nameOrNull(country.getGovernmentForm()))  \/\/values (? ? ? ?)                 .returning()  \/\/returning                 .fetchOne()  \/\/*                 .into(Country.class);     }<\/code><\/pre>\n<p>  \u041a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e. \u0412\u043f\u0440\u043e\u0447\u0435\u043c, \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430\u043c \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 ID \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 \u0431\u0430\u0437\u0435 \u0438 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u044d\u0442\u043e \u0443\u0447\u0435\u0441\u0442\u044c. \u0415\u0441\u043b\u0438 \u0436\u0435 \u043c\u044b \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0447\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435:<\/p>\n<pre><code class=\"java\">.values(null, country.getName(), country.getPopulation(), nameOrNull(country.getGovernmentForm()))<\/code><\/pre>\n<p>  \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c <\/p>\n<pre><code class=\"java\">org.postgresql.util.PSQLException: \u041e\u0428\u0418\u0411\u041a\u0410: \u043d\u0443\u043b\u0435\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u0441\u0442\u043e\u043b\u0431\u0446\u0435 &quot;id&quot; \u043d\u0430\u0440\u0443\u0448\u0430\u0435\u0442 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 NOT NULL<\/code><\/pre>\n<p>  \u0412\u043f\u0440\u043e\u0447\u0435\u043c, \u0435\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0438 ID \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0431\u044b \u043f\u0440\u043e\u043a\u0430\u0442\u0438\u043b. \u041d\u0430\u043c \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441, \u0437\u0430\u0434\u0430\u0432 \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043f\u043e\u043b\u044e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u0422\u0430\u043a \u0442\u043e\u0436\u0435 \u043c\u043e\u0436\u043d\u043e:<\/p>\n<pre><code class=\"java\">    public Country insert(Country country) {         return dsl.insertInto(Countries.COUNTRIES)                 .set(Countries.COUNTRIES.NAME, country.getName())                 .set(Countries.COUNTRIES.POPULATION, country.getPopulation())                 .set(Countries.COUNTRIES.GOVERNMENT_FORM, nameOrNull(country.getGovernmentForm()))                 .returning()                 .fetchOne()                 .into(Country.class);     }<\/code><\/pre>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043c\u044b \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0441\u0435\u0442\u0438\u043c \u043e\u0431\u044a\u0435\u043a\u0442 \u0432 \u043f\u043e\u043b\u0435. \u042d\u0442\u043e\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0432\u043f\u043e\u043b\u043d\u0435 \u0440\u0430\u0431\u043e\u0447\u0438\u0439, \u043d\u043e \u0435\u0441\u0442\u044c \u0438 \u043f\u043e\u043b\u0443\u0447\u0448\u0435. \u0411\u044b\u043b\u043e \u0431\u044b \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0432\u0435\u0441\u044c \u043e\u0431\u044a\u0435\u043a\u0442, \u043a\u0430\u043a \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0432 Spring Data JPA:<\/p>\n<pre><code class=\"java\">repository.save(country);<\/code><\/pre>\n<p>  \u041c\u043e\u0436\u043d\u043e \u0438 \u0442\u0430\u043a. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043c\u0430\u043f\u0438\u0442\u044c \u043d\u0430\u0448\u0443 \u043c\u043e\u0434\u0435\u043b\u044c \u0432 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c extends Record \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043d\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"java\">    public Country insert(Country country) {         return dsl.insertInto(Countries.COUNTRIES)                 .set(dsl.newRecord(Countries.COUNTRIES, country))  \/\/\u043c\u0430\u043f\u0438\u043c \u043c\u043e\u0434\u0435\u043b\u044c \u0432 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c                 .returning()                 .fetchOptional()                 .orElseThrow(() -&gt; new DataAccessException(&quot;Error inserting entity: &quot; + country.getId()))                 .into(Country.class);     }<\/code><\/pre>\n<p>  \u042d\u0442\u043e\u0442 \u0441\u043f\u043e\u0441\u043e\u0431 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u043c \u0434\u043b\u044f \u0442\u0435\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u043c\u0430\u043f\u0438\u043d\u0433. \u041d\u043e \u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 \u043c\u0430\u043f\u0438\u043d\u0433\u0430 \u0431\u0443\u0434\u0435\u0442 \u043d\u0438\u0436\u0435.<\/p>\n<p>  \u041a\u0430\u043a \u043c\u044b \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438, \u0434\u0430\u043d\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u0446\u0435\u043b\u0438\u043a\u043e\u043c. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0412\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 fetch(). \u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u044d\u0442\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"java\">    public Long insertAndReturnId(Country country) {         return dsl.insertInto(Countries.COUNTRIES)                 .set(dsl.newRecord(Countries.COUNTRIES, country))                 .returning(Countries.COUNTRIES.ID) \/\/\u0432 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u043c Record \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 - id                 .fetchOptional()                 .orElseThrow(() -&gt; new DataAccessException(&quot;Error inserting entity: &quot; + country.getId()))                 .get(Countries.COUNTRIES.ID); \/\/\u0434\u043e\u0441\u0442\u0430\u0451\u043c id     }<\/code><\/pre>\n<p>  \u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u043e, \u043d\u043e, \u043e\u043f\u044f\u0442\u044c \u0436\u0435, \u0441 \u0447\u0435\u043c \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c.<\/p>\n<p>  \u041d\u0430\u043f\u0438\u0448\u0435\u043c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b CRUD.<\/p>\n<h3>Update<\/h3>\n<p>  SQL-\u0437\u0430\u043f\u0440\u043e\u0441:<\/p>\n<pre><code class=\"sql\">update countries set name            = '\u042d\u0440\u0438\u0442\u0440\u0435\u044f',     government_form = 'CONFEDERATE',     population      = 100500 where id = 1 returning *;<\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0440\u043e\u0441 JOOQ:<\/p>\n<pre><code class=\"java\">    public Country update(Country country) {         return dsl.update(Countries.COUNTRIES)                 .set(dsl.newRecord(Countries.COUNTRIES, country))                 .where(Countries.COUNTRIES.ID.eq(country.getId()))                 .returning()                 .fetchOptional()                 .orElseThrow(() -&gt; new DataAccessException(&quot;Error updating entity: &quot; + country.getId()))                 .into(Country.class);     }<\/code><\/pre>\n<p>  <\/p>\n<h3>Select<\/h3>\n<p>  \u0417\u0430\u043f\u0440\u043e\u0441 \u0432 SQL \u0431\u044b\u043b \u0431\u044b \u0442\u0430\u043a\u0438\u043c:<\/p>\n<pre><code class=\"sql\">select * from countries c where id = ?;<\/code><\/pre>\n<p>  \u0412 JOOQ \u0437\u0430\u043f\u0440\u043e\u0441 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e:<\/p>\n<pre><code class=\"java\">    public Country find(Long id) {         return dsl.selectFrom(Countries.COUNTRIES) \/\/select * from countries                 .where(Countries.COUNTRIES.ID.eq(id))  \/\/where id = ?                 .fetchAny()  \/\/\u0437\u0434\u0435\u0441\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c, \u0447\u0442\u043e \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0432\u0435\u0440\u043d\u0443\u0442\u044c                 .into(Country.class);     }<\/code><\/pre>\n<p>  <\/p>\n<h3>Delete<\/h3>\n<p>  \u0415\u0441\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0430\u043c \u043d\u0435\u0447\u0435\u0433\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c. \u0422\u0430\u043a\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u0442\u0440\u043e\u043d\u0443\u0442\u044b\u0445 \u0441\u0442\u0440\u043e\u043a. \u0412 delete \u043d\u0430\u043c \u043d\u0435\u0447\u0435\u0433\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c, \u043d\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c, \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u043c \u043f\u043e\u043b\u0435\u0437\u043d\u0430.<\/p>\n<pre><code class=\"java\">    public Boolean delete(Long id) {         return dsl.deleteFrom(Countries.COUNTRIES)                 .where(Countries.COUNTRIES.ID.eq(id))                 .execute() == 1;     }<\/code><\/pre>\n<p>  \u041c\u044b \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0443. \u0417\u043d\u0430\u0447\u0438\u0442, SQL \u0437\u0430\u043f\u0440\u043e\u0441 \u0432\u0435\u0440\u043d\u0451\u0442 \u043d\u0430\u043c \u0447\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435:<\/p>\n<pre><code class=\"sql\">1 row affected in 5 ms<\/code><\/pre>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0438\u0432 \u0442\u0430\u043a\u043e\u0439 \u043e\u0442\u0432\u0435\u0442, \u043c\u044b \u0442\u043e\u0447\u043d\u043e \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u0441\u0442\u0440\u043e\u043a\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u0430. \u042d\u0442\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0439.<\/p>\n<h2>\u042d\u0442\u043e \u0431\u044b\u043b\u0430 \u043d\u0435 \u0441\u043a\u0430\u0437\u043e\u0447\u043a\u0430. \u042d\u0442\u043e \u0431\u044b\u043b\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043c\u0430\u0437\u043e\u0447\u043a\u0430. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0448\u0442\u0430\u0442\u043d\u043e\u0433\u043e \u043c\u0430\u043f\u0435\u0440\u0430 \u0434\u043b\u044f \u0442\u043e\u043d\u043a\u043e\u0433\u043e \u043c\u0430\u043f\u0438\u043d\u0433\u0430 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0432 Record \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e<\/h2>\n<p>  \u00ab\u041e\u043a\u0435\u0439\u00bb, \u2014 \u0441\u043a\u0430\u0436\u0435\u0448\u044c \u0442\u044b, \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044c, \u00ab\u0430 \u0433\u0434\u0435 \u043e\u0434\u0438\u043d-\u043a\u043e-\u043c\u043d\u043e\u0433\u0438\u043c, \u0451\u043c\u0430\u0451? \u0427\u0442\u043e-\u0442\u043e \u044f \u043d\u0435 \u0443\u0432\u0438\u0434\u0435\u043b \u043c\u043e\u043c\u0435\u043d\u0442\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c Country \u043f\u0440\u0438\u0440\u0430\u0441\u0442\u0430\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e\u043c City.\u00bb<\/p>\n<p>  \u0418 \u0431\u0443\u0434\u0435\u0448\u044c \u043f\u0440\u0430\u0432. \u042d\u0442\u043e \u043d\u0435 Hibernate, \u0437\u0434\u0435\u0441\u044c \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0432\u0440\u0443\u0447\u043d\u0443\u044e. \u0412\u0441\u0435\u0433\u043e-\u0442\u043e \u043d\u0430\u0434\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a City, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 id = country.getId(). \u042f \u0443\u0436\u0435 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u043b \u043c\u0435\u0442\u043e\u0434 into(), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0448\u0442\u0430\u0442\u043d\u044b\u0439 \u043c\u0430\u043f\u043f\u0435\u0440 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u043c\u0430\u043f\u0438\u0442\u044c Record \u0432 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c. \u041d\u043e \u0432 JOOQ \u0435\u0441\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 map(), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u0441 Record \u0432\u0441\u0451, \u0447\u0442\u043e \u043c\u044b \u0437\u0430\u0445\u043e\u0442\u0438\u043c. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0435\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438 \u0434\u043e\u043f\u0438\u0448\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0433\u043e\u0440\u043e\u0434\u043e\u0432:<\/p>\n<pre><code class=\"java\">    public Country find(Long id) {         return dsl.selectFrom(Countries.COUNTRIES)                 .where(Countries.COUNTRIES.ID.eq(id))                 .fetchAny()                 .map(r -&gt; {                     Country country = r.into(Country.class);                     country.setCities(cityRepository.findAll(Cities.CITIES.COUNTRY_ID.eq(country.getId())));                     return country;                 });     }<\/code><\/pre>\n<p>  \u041a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u044b \u043c\u0430\u043f\u0438\u043c Record \u0432 Country, \u0430 \u043f\u043e\u0442\u043e\u043c \u0434\u0435\u043b\u0430\u0435\u043c \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u0437\u0430\u043f\u0440\u043e\u0441 \u0432 cities, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432\u0441\u0435 City \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0439 Country \u0438 \u0441\u0435\u0442\u0438\u043c \u0438\u0445 \u0432 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c.<\/p>\n<p>  \u041d\u043e \u0442\u0430\u043a\u0438\u0445 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0434\u0435\u0441\u044f\u0442\u043a\u0438, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442, \u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0434\u0435\u0441\u044f\u0442\u043a\u0438. \u0418 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043f\u0440\u044f\u043c\u043e \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 \u2014 \u0442\u0430\u043a\u043e\u0435. \u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u2014 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0430\u043f\u0435\u0440 \u0438 \u0441\u043b\u043e\u0436\u0438\u0442\u044c \u0432\u0441\u0435 \u044d\u0442\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0442\u0443\u0434\u0430.<\/p>\n<pre><code class=\"java\">@RequiredArgsConstructor @Component public class CountryRecordMapper implements RecordMapper&lt;CountriesRecord, Country&gt; {      private final CityRepository cityRepository;      @Override     public Country map(CountriesRecord record) {         Country country = record.into(Country.class);         country.setCities(cityRepository.findAll(Cities.CITIES.COUNTRY_ID.eq(country.getId())));         return country;     } }<\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0440\u043e\u0441 \u0442\u0435\u043f\u0435\u0440\u044c \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"java\">    public Country findWithCustomMapper(Long id) {         return dsl.selectFrom(Countries.COUNTRIES)                 .where(Countries.COUNTRIES.ID.eq(id))                 .fetchAny()                 .map(r -&gt; countryRecordMapper.map((CountriesRecord) r));     }<\/code><\/pre>\n<p>  \u041e\u043d \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u0435\u0435, \u0438 \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438.<\/p>\n<h3>\u041e\u043a\u0435\u0439, \u043c\u044b \u043d\u0430\u0443\u0447\u0438\u043b\u0438\u0441\u044c \u043c\u0430\u043f\u0438\u0442\u044c Record \u0432 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c, \u043d\u043e \u043a\u0430\u043a \u0431\u044b\u0442\u044c \u0441 \u0442\u043e\u043d\u043a\u043e\u0439 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u043e\u0439 \u043c\u0430\u043f\u0438\u043d\u0433\u0430 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0432 Record?<\/h3>\n<p>  \u041f\u043e\u043a\u0430 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0442\u0430\u043a\u0430\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f:<\/p>\n<pre><code class=\"java\">.set(dsl.newRecord(Countries.COUNTRIES, country))<\/code><\/pre>\n<p>  \u0423\u0436\u0435 \u0445\u043e\u0440\u043e\u0448\u043e, \u043d\u043e \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u043e \u0437\u0430\u043c\u0430\u043f\u0438\u0442\u044c \u043a\u0430\u043a\u043e\u0435-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u043e\u043b\u0435? \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443 \u043d\u0430\u0441 \u0442\u0430\u043c LocalDateTime, \u0430 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0434\u043b\u044f PostgreSQL \u043f\u043e \u0442\u0438\u043f\u0443 timestamp \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043b OffsetDateTime. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043f\u043e\u043b\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0441\u043c\u0430\u043f\u0438\u0442\u0441\u044f \u0438 \u043d\u0435 \u0437\u0430\u043f\u0438\u0448\u0435\u0442\u0441\u044f \u0432 \u0431\u0430\u0437\u0443. \u0414\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0443\u0436\u0435 \u0434\u0440\u0443\u0433\u043e\u0439 \u043c\u0430\u043f\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u043d\u043e \u0432 \u043e\u0431\u0440\u0430\u0442\u043d\u0443\u044e \u0441\u0442\u043e\u0440\u043e\u043d\u0443.<\/p>\n<h3>\u0414\u0430, \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 mapper \u0443 \u043d\u0430\u0441 \u043d\u0430\u0439\u0434\u0451\u0442\u0441\u044f unmapper<\/h3>\n<p>  \u041e\u043d \u0442\u0430\u043a \u0438 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f. \u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0435\u0433\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u0430.<\/p>\n<pre><code class=\"java\">@Component @RequiredArgsConstructor public class CountryRecordUnmapper implements RecordUnmapper&lt;Country, CountriesRecord&gt; {      private final DSLContext dsl;      @Override     public CountriesRecord unmap(Country country) throws MappingException {         CountriesRecord record = dsl.newRecord(Countries.COUNTRIES, country);         record.setPopulation(-1);         return record;     } }<\/code><\/pre>\n<p>  Insert \u0441 \u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"java\">    public Country insertWithUnmapper(Country country) {         return dsl.insertInto(Countries.COUNTRIES)                 .set(countryRecordUnmapper.unmap(country))                 .returning()                 .fetchOptional()                 .orElseThrow(() -&gt; new DataAccessException(&quot;Error inserting entity: &quot; + country.getId()))                 .into(Country.class);     }<\/code><\/pre>\n<p>  \u041a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0442\u043e\u0436\u0435 \u0432\u043f\u043e\u043b\u043d\u0435.<\/p>\n<h2>\u0412\u044b\u0432\u043e\u0434\u044b \u0438 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f<\/h2>\n<p>  \u041b\u0438\u0447\u043d\u043e \u043c\u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f Hibernate. \u041d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u0434\u043b\u044f 90+% \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u043e\u043f\u0440\u0430\u0432\u0434\u0430\u043d\u043e. \u041d\u043e \u0435\u0441\u043b\u0438 \u0442\u044b, \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044c, \u0445\u043e\u0447\u0435\u0448\u044c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441, \u0442\u0435\u0431\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u0434\u043e\u0439\u0434\u0451\u0442 JOOQ \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u0430\u044f \u043f\u043e\u0445\u043e\u0436\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430.<\/p>\n<p>  \u041a\u0430\u043a \u0432\u0441\u0435\u0433\u0434\u0430, \u0432\u044b\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044e \u0443\u0447\u0435\u0431\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442. \u041e\u043d \u043b\u0435\u0436\u0438\u0442 <a href=\"https:\/\/github.com\/promoscow\/jooq-example\"><u>\u0442\u0443\u0442<\/u>.<\/a><\/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\/post\/488522\/\"> https:\/\/habr.com\/ru\/post\/488522\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/488522\/\">\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043d\u0435 \u0431\u0443\u0434\u0443 \u0442\u043e\u043f\u0438\u0442\u044c \u0437\u0430 JOOQ. \u042f \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u044e Hibernate \u0438 \u0432\u0441\u044e \u0441\u0438\u043b\u0443 Spring Data JPA, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0437\u0430 \u043d\u0438\u043c \u0441\u0442\u043e\u0438\u0442. \u041d\u043e \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u043e \u043d\u0438\u0445.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/wt\/-0\/co\/wt-0condklmkd6zkb2ag_a46vb4.png\"><\/p>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f Hibernate \u0438 Spring Data JPA, \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0434\u0443\u043c\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u0445 \u2014 \u0437\u043d\u0430\u0439 \u0441\u0442\u0430\u0432\u044c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0438 \u043f\u0438\u0448\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0435 \u0438\u043c\u0435\u043d\u0430 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u2014 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u0430 \u0442\u0435\u0431\u044f \u0441\u0434\u0435\u043b\u0430\u044e\u0442 \u044d\u0442\u0438 \u0434\u0432\u0430 \u043c\u043e\u043d\u0441\u0442\u0440\u0430. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0432 JOOQ, \u043a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e \u0434\u043b\u044f \u043c\u043d\u043e\u0433\u0438\u0445, \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043c\u0430\u043b\u043e\u0441\u0442\u044c \u043d\u0430\u043f\u0440\u044f\u0447\u044c\u0441\u044f \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c <i>findAllByUserId(Long userId)<\/i>.  <\/p>\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-299540","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/299540","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=299540"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/299540\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=299540"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=299540"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=299540"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}