{"id":444623,"date":"2025-01-10T21:00:05","date_gmt":"2025-01-10T21:00:05","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=444623"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=444623","title":{"rendered":"<span>JOOQ \u2014 \u043d\u0435 \u0437\u0430\u043c\u0435\u043d\u0430 Hibernate. \u041e\u043d\u0438 \u0440\u0435\u0448\u0430\u044e\u0442 \u0440\u0430\u0437\u043d\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u0433\u043e\u0434-\u043f\u043e\u043b\u0442\u043e\u0440\u0430 \u044f \u043d\u0430\u0442\u044b\u043a\u0430\u044e\u0441\u044c \u043d\u0430 \u0441\u0442\u0430\u0442\u044c\u0438 \u0438 \u0434\u043e\u043a\u043b\u0430\u0434\u044b (\u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432 \u0430\u043d\u0433\u043b\u043e\u044f\u0437\u044b\u0447\u043d\u043e\u043c \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0435) \u043e \u0442\u043e\u043c, \u0447\u0442\u043e JOOQ \u2013 \u044d\u0442\u043e \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0438 \u0431\u043e\u043b\u0435\u0435 \u043a\u0440\u0443\u0442\u0430\u044f \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0430 Hibernate. \u0422\u0435\u0437\u0438\u0441\u044b \u0437\u0432\u0443\u0447\u0430\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<ol>\n<li>\n<p>JOOQ \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u0430\u043c \u0432\u0441\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0432 compile time, \u0430 Hibernate \u2013 \u043d\u0435\u0442!<\/p>\n<\/li>\n<li>\n<p>\u0412 Hibernate \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u0435 \u0438 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u0430 \u0432 JOOQ \u0432\u0441\u0435 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e!<\/p>\n<\/li>\n<li>\n<p>\u0412 Hibernate \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u044b\u0435 \u0438 \u044d\u0442\u043e \u043f\u043b\u043e\u0445\u043e. \u0410 JOOQ \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u0441\u0435 entity \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u043c\u0438 (\u043f\u0440\u0438\u0432\u0435\u0442 \u0424\u041f)!<\/p>\n<\/li>\n<li>\n<p>\u0412 JOOQ \u043d\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u00ab\u043c\u0430\u0433\u0438\u0438\u00bb \u0441 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f\u043c\u0438!<\/p>\n<\/li>\n<\/ol>\n<p>\u0421\u043a\u0430\u0436\u0443 \u0441\u0440\u0430\u0437\u0443, \u0447\u0442\u043e \u044f \u0441\u0447\u0438\u0442\u0430\u044e JOOQ \u043e\u0442\u043b\u0438\u0447\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 (\u0438\u043c\u0435\u043d\u043d\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439, \u0430 \u043d\u0435 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u043c, \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 Hibernate). \u041e\u043d \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e \u0441\u0432\u043e\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u2013 \u0440\u0430\u0431\u043e\u0442\u043e\u0439 \u0441 SQL \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043b\u043e\u0432\u0438\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043e\u0448\u0438\u0431\u043e\u043a \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438.<\/p>\n<p>\u041d\u043e \u043a\u043e\u0433\u0434\u0430 \u044f \u0441\u043b\u044b\u0448\u0443 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442, \u0447\u0442\u043e \u0432\u0440\u0435\u043c\u044f Hibernate \u043f\u0440\u043e\u0448\u043b\u043e \u0438 \u043f\u043e\u0440\u0430 \u0432\u0441\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430 JOOQ, \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u044d\u0442\u043e \u0437\u0432\u0443\u0447\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u0442\u043e, \u0447\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0411\u0414 \u043f\u0440\u043e\u0448\u043b\u043e \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e NoSQL. \u0417\u0432\u0443\u0447\u0438\u0442 \u0441\u043c\u0435\u0448\u043d\u043e? \u041d\u043e \u043f\u043e \u043c\u0435\u0440\u043a\u0430\u043c \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0431\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u0432\u0447\u0435\u0440\u0430 \u0442\u0430\u043a\u0438\u0435 \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440\u044b \u0432\u0435\u043b\u0438\u0441\u044c \u0432\u043f\u043e\u043b\u043d\u0435 \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u043e.<\/p>\n<p>\u042f \u0434\u0443\u043c\u0430\u044e, \u0434\u0435\u043b\u043e \u043a\u0440\u043e\u0435\u0442\u0441\u044f \u0432 \u043d\u0435\u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0438 \u043a\u043e\u0440\u043d\u0435\u0432\u044b\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0435\u0448\u0430\u044e\u0442 \u044d\u0442\u0438 \u0434\u0432\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430. \u042d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435\u0439 \u044f \u0445\u043e\u0447\u0443 \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u043d\u0430 \u044d\u0442\u0438 \u0432\u043e\u043f\u0440\u043e\u0441\u044b. \u041c\u044b \u0441 \u0432\u0430\u043c\u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c:<\/p>\n<ol>\n<li>\n<p>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Transaction Script?<\/p>\n<\/li>\n<li>\n<p>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Domain Model?<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u043a\u0438\u0435 \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0440\u0435\u0448\u0430\u044e\u0442 Hibernate \u0438 JOOQ?<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443 \u043e\u0434\u0438\u043d \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0437\u0430\u043c\u0435\u043d\u043e\u0439 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0438 \u043a\u0430\u043a \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0441\u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c?<\/p>\n<\/li>\n<\/ol>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/c5c\/709\/ec5\/c5c709ec544ceba2d1984c95b4661718.jpg\" alt=\"\u041c\u0435\u043c\u043d\u044b\u0439 \u043a\u0430\u0432\u0435\u0440 \u043a \u0441\u0442\u0430\u0442\u044c\u0435\" title=\"\u041c\u0435\u043c\u043d\u044b\u0439 \u043a\u0430\u0432\u0435\u0440 \u043a \u0441\u0442\u0430\u0442\u044c\u0435\" width=\"500\" height=\"545\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c5c\/709\/ec5\/c5c709ec544ceba2d1984c95b4661718.jpg\" data-blurred=\"true\"\/><\/p>\n<div><figcaption>\u041c\u0435\u043c\u043d\u044b\u0439 \u043a\u0430\u0432\u0435\u0440 \u043a \u0441\u0442\u0430\u0442\u044c\u0435<\/figcaption><\/div>\n<\/figure>\n<h2>Transaction Script<\/h2>\n<p>\u0421\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438 \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0411\u0414 \u2013 \u043f\u0430\u0442\u0442\u0435\u0440\u043d <a href=\"https:\/\/martinfowler.com\/eaaCatalog\/transactionScript.html\" rel=\"noopener noreferrer nofollow\">Transaction Script<\/a>. \u0415\u0441\u043b\u0438 \u043a\u0440\u0430\u0442\u043a\u043e, \u0432\u044b \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0443\u0435\u0442\u0435 \u0432\u0441\u044e \u0432\u0430\u0448\u0443 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443 \u0432 \u0432\u0438\u0434\u0435 \u043d\u0430\u0431\u043e\u0440\u0430 SQL-\u043a\u043e\u043c\u0430\u043d\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u0442\u0435 \u0432 \u043e\u0434\u043d\u0443 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e. \u0427\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u043a\u0430\u043a\u0443\u044e-\u0442\u043e \u0431\u0438\u0437\u043d\u0435\u0441-\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e, \u0438 \u043e\u043d \u0436\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d \u043e\u0434\u043d\u043e\u0439 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0435\u0439.<\/p>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043c\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043f\u0438\u043a\u0435\u0440\u0430\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0441\u0432\u043e\u0439 \u0434\u043e\u043a\u043b\u0430\u0434 \u043d\u0430 \u043a\u043e\u043d\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u044e (\u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u0443\u0434\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0434\u043e\u043a\u043b\u0430\u0434\u0430). \u0415\u0441\u043b\u0438 \u043c\u044b \u0441\u043b\u0435\u0434\u0443\u0435\u043c \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0443 Transaction Script, \u0442\u043e \u043c\u0435\u0442\u043e\u0434 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0434\u043e\u043a\u043b\u0430\u0434\u0430 \u043d\u0430 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a (\u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0434\u043b\u044f SQL \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e <a href=\"https:\/\/jdbi.org\/jdbi2\/five_minute_intro\/\" rel=\"noopener noreferrer nofollow\">JDBI<\/a>):<\/p>\n<pre><code class=\"java\">@Service @RequiredArgsConstructor public class TalkService {     private final Jdbi jdbi;      public TalkSubmittedResult submitTalk(Long speakerId, String title) {         var talkId = jdbi.inTransaction(handle -&gt; {             \/\/ \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u044b\u0445 \u0434\u043e\u043a\u043b\u0430\u0434\u043e\u0432 \u0443 \u0441\u043f\u0438\u043a\u0435\u0440\u0430             var acceptedTalksCount =                 handle.select(\"SELECT count(*) FROM talk WHERE speaker_id = :id AND status = 'ACCEPTED'\")                     .bind(\"id\", speakerId)                     .mapTo(Long.class)                     .one();             \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u0441\u043f\u0438\u043a\u0435\u0440 \u043e\u043f\u044b\u0442\u043d\u044b\u043c             var experienced = acceptedTalksCount &gt;= 10;             \/\/ \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u043e\u043a\u043b\u0430\u0434\u043e\u0432             var maxSubmittedTalksCount = experienced ? 5 : 3;             var submittedTalksCount =                 handle.select(\"SELECT count(*) FROM talk WHERE speaker_id = :id AND status = 'SUBMITTED'\")                     .bind(\"id\", speakerId)                     .mapTo(Long.class)                     .one();             \/\/ \u0415\u0441\u043b\u0438 \u043f\u0440\u0435\u0432\u044b\u0448\u0435\u043d\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0434\u043e\u043a\u043b\u0430\u0434\u043e\u0432 \u043d\u0430 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u0438, \u043a\u0438\u0434\u0430\u0435\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435             if (submittedTalksCount &gt;= maxSubmittedTalksCount) {                 throw new CannotSubmitTalkException(\"Submitted talks count is maximum: \" + maxSubmittedTalksCount);             }             return handle.createUpdate(                     \"\"\"                         INSERT INTO talk (speaker_id, status, title)                         VALUES (:id, 'SUBMITTED', :title)                         \"\"\"                 ).bind(\"id\", speakerId)                        .bind(\"title\", title)                        .executeAndReturnGeneratedKeys(\"id\")                        .mapTo(Long.class)                        .one();         });         return new TalkSubmittedResult(talkId);     }   }<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<ol>\n<li>\n<p>\u0421\u0447\u0438\u0442\u0430\u0435\u043c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043f\u0438\u043a\u0435\u0440 \u0443\u0436\u0435 \u043f\u043e\u0434\u0430\u043b \u0434\u043e\u043a\u043b\u0430\u0434\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c, \u043d\u0435 \u043f\u0440\u0435\u0432\u044b\u0448\u0435\u043d\u043e \u043b\u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u043e\u043a\u043b\u0430\u0434\u043e\u0432 \u043d\u0430 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u043e\u043a, \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u0434\u043e\u043a\u043b\u0430\u0434 \u0432 \u0441\u0442\u0430\u0442\u0443\u0441\u0435 <code>SUBMITTED<\/code>.<\/p>\n<\/li>\n<\/ol>\n<blockquote>\n<p>\u0417\u0434\u0435\u0441\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u0430 \u0433\u043e\u043d\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u043e \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u043f\u043e\u0432\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u043e\u0441\u0442\u0440\u044f\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 pessimistic \u0438\u043b\u0438 optimistic locking.<\/p>\n<\/blockquote>\n<p>\u041f\u043b\u044e\u0441\u044b \u0443 \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435:<\/p>\n<ol>\n<li>\n<p>SQL, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0441\u044f, \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u0435\u043d \u0438 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c. \u0415\u0433\u043e \u043b\u0435\u0433\u043a\u043e \u043f\u043e\u0434\u0442\u044e\u043d\u0438\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c performance \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u0442\u044c \u0438\u0437 \u0411\u0414 \u043b\u0438\u0448\u044c \u043d\u0443\u0436\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<\/li>\n<li>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f JOOQ, \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0449\u0435, \u043a\u043e\u0440\u043e\u0447\u0435, \u0434\u0430 \u0435\u0449\u0435 \u0438 \u0441\u043e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0435\u0439!<\/p>\n<\/li>\n<\/ol>\n<p>\u041c\u0438\u043d\u0443\u0441\u044b \u0436\u0435 \u0442\u0430\u043a\u0438\u0435:<\/p>\n<ol>\n<li>\n<p>\u041d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e unit-\u0442\u0435\u0441\u0442\u043e\u0432. \u041e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0443\u0436\u043d\u044b \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 (\u0438 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u043d\u043e\u0433\u043e).<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0434\u043e\u043c\u0435\u043d \u0441\u043b\u043e\u0436\u043d\u044b\u0439, \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442 \u043a \u0441\u043f\u0430\u0433\u0435\u0442\u0442\u0438-\u043a\u043e\u0434\u0443.<\/p>\n<\/li>\n<li>\n<p>\u0420\u0438\u0441\u043a \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u044b\u043c \u0431\u0430\u0433\u0430\u043c \u043f\u0440\u0438 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u044b.<\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0432\u0430\u043b\u0438\u0434\u0435\u043d \u0438 \u043b\u043e\u0433\u0438\u0447\u0435\u043d, \u0435\u0441\u043b\u0438 \u0432 \u0432\u0430\u0448\u0435\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0442\u0430\u043a\u0436\u0435 \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u043d\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442 \u0443\u0441\u043b\u043e\u0436\u043d\u0435\u043d\u0438\u044f. \u041d\u043e \u0447\u0430\u0441\u0442\u043e \u0434\u043e\u043c\u0435\u043d\u044b \u0431\u044b\u0432\u0430\u044e\u0442 \u043a\u0440\u0443\u043f\u043d\u0435\u0435. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0430.<\/p>\n<h2>\u0414\u043e\u043c\u0435\u043d\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c<\/h2>\n<p>\u0418\u0434\u0435\u044f \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 <a href=\"https:\/\/martinfowler.com\/eaaCatalog\/domainModel.html\" rel=\"noopener noreferrer nofollow\">Domain Model<\/a> \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u044b \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0437\u0430\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u043c \u043d\u0430\u0448\u0443 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043d\u0430 SQL-\u043a\u043e\u043c\u0430\u043d\u0434\u044b. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e, \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0434\u043e\u043c\u0435\u043d\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b (\u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 Java, \u043a\u043b\u0430\u0441\u0441\u044b), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0438 \u0445\u0440\u0430\u043d\u044f\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u0434\u043e\u043c\u0435\u043d\u043d\u044b\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044f\u0445.<\/p>\n<blockquote>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043e \u0440\u0430\u0437\u043d\u0438\u0446\u0435 \u0430\u043d\u0435\u043c\u0438\u0447\u043d\u043e\u0439 \u0438 \u0431\u043e\u0433\u0430\u0442\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u044f\u0445. \u0415\u0441\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u044f \u043f\u0438\u0441\u0430\u043b \u043e\u0431 \u044d\u0442\u043e\u043c <a href=\"https:\/\/dev.to\/kirekov\/rich-domain-model-with-hibernate-445k\" rel=\"noopener noreferrer nofollow\">\u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e<\/a>.<\/p>\n<\/blockquote>\n<p>\u0411\u0438\u0437\u043d\u0435\u0441-\u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 (\u0441\u0435\u0440\u0432\u0438\u0441\u044b) \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0438 \u043d\u0435 \u0437\u0430\u0432\u044f\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432 \u0411\u0414.<\/p>\n<blockquote>\n<p>\u042f\u0441\u043d\u043e\u0435 \u0434\u0435\u043b\u043e, \u0447\u0442\u043e \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0443 \u043d\u0430\u0441 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043c\u0438\u043a\u0441 \u0438\u0437 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u0434\u043e\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438 \u0438 \u043f\u0440\u044f\u043c\u044b\u043c\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438 \u0432 \u0411\u0414 \u0441 \u0446\u0435\u043b\u044c\u044e \u0441\u043e\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0439 \u043f\u043e performance. \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u0445\u0440\u0435\u0441\u0442\u043e\u043c\u0430\u0442\u0438\u0439\u043d\u043e\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435 \u043f\u0440\u0438 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0438 Domain Model, \u043a\u043e\u0433\u0434\u0430 \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u044f\u0446\u0438\u044f \u0438 \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u044f \u043d\u0435 \u043d\u0430\u0440\u0443\u0448\u0430\u044e\u0442\u0441\u044f.<\/p>\n<\/blockquote>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u0440\u0435\u0447\u044c \u0438\u0434\u0435\u0442 \u043e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044f\u0445 <code>Speaker<\/code> \u0438 <code>Talk<\/code>, \u043a\u0430\u043a \u0431\u044b\u043b\u043e \u0440\u0430\u043d\u0435\u0435, \u0434\u043e\u043c\u0435\u043d\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"java\">@AllArgsConstructor public class Speaker {     private Long id;     private String firstName;     private String lastName;     private List&lt;Talk&gt; talks;      public Talk submitTalk(String title) {         boolean experienced = countTalksByStatus(Status.ACCEPTED) &gt;= 10;         int maxSubmittedTalksCount = experienced ? 3 : 5;         if (countTalksByStatus(Status.SUBMITTED) &gt;= maxSubmittedTalksCount) {             throw new CannotSubmitTalkException(               \"Submitted talks count is maximum: \" + maxSubmittedTalksCount);         }         Talk talk = Talk.newTalk(this, Status.SUBMITTED, title);         talks.add(talk);         return talk;     }        public void acceptTalk(int talkNumber) {         Talk talk = talkByNumber(talkNumber);         talk.setStatus(status -&gt; {             if (!status.equals(Status.SUBMITTED)) {                 throw new CannotAcceptTalkException(\"\");             }             return Status.ACCEPTED;         });     }      public void rejectTalk(int talkNumber) {         Talk talk = talkByNumber(talkNumber);         talk.setStatus(status -&gt; {             if (!status.equals(Status.SUBMITTED)) {                 throw new CannotRejectTalkException(\"\");             }             return Status.REJECTED;         });     }      private Talk talkByNumber(int number) {         return talks.stream().filter(t -&gt; Objects.equals(t.getNumber(), number)).findFirst()             .orElseThrow();     }      private long countTalksByStatus(Talk.Status status) {         return talks.stream().filter(t -&gt; t.getStatus().equals(status)).count();     } }  @AllArgsConstructor public class Talk {     private Long id;     private Speaker speaker;     private Status status;     private String title;     private int talkNumber;      void setStatus(Function&lt;Status, Status&gt; fnStatus) {         this.status = fnStatus.apply(this.status);     }        public enum Status {         SUBMITTED, ACCEPTED, REJECTED     } }<\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u043e\u0442\u043a\u0443\u0434\u0430-\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0438 \u043a\u0443\u0434\u0430-\u0442\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0434\u043e\u043c\u0435\u043d\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <a href=\"https:\/\/martinfowler.com\/eaaCatalog\/repository.html\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439<\/a>. \u042d\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0430\u0433\u0440\u0435\u0433\u0430\u0442, \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043d\u0430\u0434 \u043d\u0438\u043c \u043a\u0430\u043a\u0438\u0445-\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0441\u0430\u043c\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u043d\u0430\u0441 \u043d\u0435 \u0432\u043e\u043b\u043d\u0443\u0435\u0442, \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043b\u0438\u0448\u044c \u0435\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441.<\/p>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u0443 \u043d\u0430\u0441 \u0442\u0430\u043a\u043e\u0439 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439:<\/p>\n<pre><code class=\"java\">public interface SpeakerRepository {     Speaker findById(Long id);     void save(Speaker speaker); }<\/code><\/pre>\n<p>\u0422\u043e\u0433\u0434\u0430 \u0441\u0435\u0440\u0432\u0438\u0441 \u043f\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 <code>submitTalk<\/code> \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"java\">@Service @RequiredArgsConstructor public class SpeakerService {     private final SpeakerRepository repo;      public TalkSubmittedResult submitTalk(Long speakerId, String title) {         Speaker speaker = repo.findById(speakerId);         Talk talk = speaker.submitTalk(title);         repo.save(speaker);         return new TalkSubmittedResult(talk.getId());     } }<\/code><\/pre>\n<p>\u041f\u043b\u044e\u0441\u044b \u0434\u043e\u043c\u0435\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0442\u0430\u043a\u0438\u0435:<\/p>\n<ol>\n<li>\n<p>\u0414\u043e\u043c\u0435\u043d\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043e\u0442\u0432\u044f\u0437\u0430\u043d\u044b \u043e\u0442 \u0434\u0435\u0442\u0430\u043b\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 (\u0442\u043e \u0435\u0441\u0442\u044c \u043e\u0442 \u0411\u0414). \u0417\u043d\u0430\u0447\u0438\u0442, \u0438\u0445 \u043b\u0435\u0433\u043a\u043e \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u044b\u043c\u0438 unit-\u0442\u0435\u0441\u0442\u0430\u043c\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0411\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0430 \u0441\u043a\u043e\u043d\u0446\u0435\u043d\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435, \u0432 \u0434\u043e\u043c\u0435\u043d\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u0445. \u0413\u043e\u0440\u0430\u0437\u0434\u043e \u043c\u0435\u043d\u044c\u0448\u0438\u0439 \u0440\u0438\u0441\u043a \u0440\u0430\u0441\u043f\u043e\u043b\u0437\u0430\u043d\u0438\u044f \u043b\u043e\u0433\u0438\u043a\u0438 \u043f\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e, \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 Transaction Script.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u0438 \u0434\u043e\u043c\u0435\u043d\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0438\u043c\u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u044b\u043c\u0438, \u0447\u0442\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043d\u0438\u043c\u0438 (\u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u0445 \u0432 \u043b\u044e\u0431\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u0438 \u043d\u0435 \u0431\u043e\u044f\u0442\u0441\u044f, \u0447\u0442\u043e \u043e\u043d \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442 \u0438\u0445 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435).<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043b\u044f \u0432 \u0434\u043e\u043c\u0435\u043d\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u0445 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430 <a href=\"https:\/\/martinfowler.com\/bliki\/ValueObject.html\" rel=\"noopener noreferrer nofollow\">Value Objects<\/a>, \u0447\u0442\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0432\u044b\u0441\u0438\u0442 \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u044c, \u043d\u043e \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0430\u043b\u0438\u0434\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u043b\u0435\u0439 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0438\u0445 \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u0438\u044f (\u043d\u0435\u043b\u044c\u0437\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c Value Object \u0441 \u043d\u0435\u0432\u0430\u043b\u0438\u0434\u043d\u044b\u043c \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u043e\u043c).<\/p>\n<\/li>\n<\/ol>\n<p>\u041a\u043e\u0440\u043e\u0447\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, \u043e\u0434\u043d\u0438 \u0441\u043f\u043b\u043e\u0448\u043d\u044b\u0435 \u043f\u043b\u044e\u0441\u044b. \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u0435\u0441\u0442\u044c \u043e\u0434\u043d\u0430 \u0432\u0430\u0436\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u0447\u0442\u043e \u0432 \u043a\u043d\u0438\u0433\u0430\u0445 \u043f\u043e Domain Driven Design, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u0438 \u043f\u0440\u043e\u0434\u0432\u0438\u0433\u0430\u0435\u0442\u0441\u044f Domain Model, \u044d\u0442\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043b\u0438\u0431\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442\u0441\u044f, \u043b\u0438\u0431\u043e \u0435\u0435 \u043a\u0430\u0441\u0430\u044e\u0442\u0441\u044f \u0432\u0441\u043a\u043e\u043b\u044c\u0437.<\/p>\n<p>\u0417\u0432\u0443\u0447\u0438\u0442 \u043e\u043d\u0430 \u0442\u0430\u043a: <strong><em>\u0430 \u043a\u0430\u043a \u0434\u043e\u043c\u0435\u043d\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u0411\u0414, \u0430 \u043f\u043e\u0442\u043e\u043c \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0442\u043d\u043e? <\/em><\/strong>\u0418\u043d\u0430\u0447\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, \u043a\u0430\u043a \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f?<\/p>\n<p>\u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0441\u0435\u0439\u0447\u0430\u0441 \u043e\u0442\u0432\u0435\u0442 \u043e\u0447\u0435\u0432\u0438\u0434\u0435\u043d. \u0412\u043e\u0437\u044c\u043c\u0438 Hibernate (\u0430 \u0435\u0449\u0435 \u043b\u0443\u0447\u0448\u0435, Spring Data JPA) \u0438 \u043d\u0435 \u043c\u0443\u0447\u0430\u0439\u0441\u044f. \u041d\u043e \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e \u043c\u044b \u043f\u043e\u043f\u0430\u043b\u0438 \u0432 \u043c\u0438\u0440, \u0433\u0434\u0435 ORM \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432 \u043d\u0435 \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043b\u0438. \u041a\u0430\u043a \u0431\u044b \u043c\u044b \u0440\u0435\u0448\u0438\u043b\u0438 \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443?<\/p>\n<h2>\u041c\u0430\u043f\u043f\u0438\u043d\u0433 \u0432 \u0411\u0414 \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0440\u0443\u043a\u0430\u043c\u0438<\/h2>\n<p>\u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0411\u0414 \u044f \u0442\u0430\u043a\u0436\u0435 \u0432\u043e\u0437\u044c\u043c\u0443 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 JDBI:<\/p>\n<pre><code class=\"java\">@AllArgsConstructor @Repository public class JdbiSpeakerRepository implements SpeakerRepository {    private final Jdbi jdbi;     @Override    public Speaker findById(Long id) {        return jdbi.inTransaction(handle -&gt; {            return handle.select(\"SELECT * FROM speaker s LEFT JOIN talk t ON t.speaker_id = s.id WHERE id = :id\")                 .bind(\"id\", speakerId)                 .mapTo(Speaker.class) \/\/ \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u043e\u043f\u0443\u0441\u0442\u0438\u043c \u043b\u043e\u0433\u0438\u043a\u0443 \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0430                 .execute();        });    }     @Override    public void save(Speaker speaker) {        jdbi.inTransaction(handle -&gt; {            \/\/ \u0441\u043b\u043e\u0436\u043d\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u043f\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435 \u0442\u043e\u0433\u043e, \u0435\u0441\u0442\u044c \u043b\u0438 speaker,            \/\/ \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 update\/insert, optimistic locking,            \/\/ \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044e \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044e Talk \u0432\u043d\u0443\u0442\u0440\u0438 speaker \u0438 \u0442 \u0434        });    } }<\/code><\/pre>\n<p>\u041f\u043e\u0434\u0445\u043e\u0434 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438 \u043f\u0440\u044f\u043c\u043e\u0439. \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u043f\u0438\u0448\u0435\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0411\u0414 \u0447\u0435\u0440\u0435\u0437 \u043b\u044e\u0431\u0443\u044e \u0443\u0434\u043e\u0431\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u043e\u0442 \u0436\u0435 JOOQ \u0438\u043b\u0438 JDBI).<\/p>\n<p>\u041d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 (\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c, \u0434\u0430\u0436\u0435 \u043d\u0430 \u0432\u0442\u043e\u0440\u043e\u0439), \u0442\u0430\u043a\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0445\u043e\u0440\u043e\u0448\u0438\u043c. \u0421\u0443\u0434\u0438\u0442\u0435 \u0441\u0430\u043c\u0438:<\/p>\n<ol>\n<li>\n<p>\u041f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u0432\u044b\u0441\u043e\u043a\u0430\u044f \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u0438 \u043a\u043e\u0434\u0430, \u043a\u0430\u043a \u0432 Transaction Script.<\/p>\n<\/li>\n<li>\n<p>\u0411\u043e\u043b\u044c\u0448\u0435 \u043d\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e integration \u0442\u0435\u0441\u0442\u0430\u043c\u0438. \u041e\u043d\u0438 \u043d\u0443\u0436\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u0432 (\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u0430\u0440\u0443 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432 E2E).<\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u0434 \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0430 \u043f\u0440\u044f\u043c\u043e \u043f\u0435\u0440\u0435\u0434 \u043d\u0430\u0448\u0438\u043c\u0438 \u0433\u043b\u0430\u0437\u0430\u043c\u0438. \u041d\u0438\u043a\u0430\u043a\u043e\u0439 Hibernate-\u043e\u0432\u0441\u043a\u043e\u0439 \u043c\u0430\u0433\u0438\u0438. \u0423\u0432\u0438\u0434\u0435\u043b \u0431\u0430\u0433? \u041d\u0430\u0448\u0435\u043b \u043d\u0443\u0436\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u0447\u043a\u0443 \u0438 \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u043b.<\/p>\n<\/li>\n<\/ol>\n<h2>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c Hibernate<\/h2>\n<p>\u041d\u043e \u0432\u0441\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0435 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043c\u0438\u0440\u0435. \u0412\u0435\u0434\u044c \u0443 \u0432\u0430\u0441 \u0432\u043f\u043e\u043b\u043d\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438:<\/p>\n<ol>\n<li>\n<p>\u0414\u043e\u043c\u0435\u043d\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043c\u043e\u0433\u0443\u0442 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c\u0441\u044f.<\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0432\u043e\u043a\u0443\u043f\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u043b\u0435\u0439 \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0442\u044c\u0441\u044f \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 Value Object (<a href=\"https:\/\/www.baeldung.com\/jpa-embedded-embeddable\" rel=\"noopener noreferrer nofollow\">Embedded<\/a> \u0432 JPA\/Hibernate).<\/p>\n<\/li>\n<li>\n<p>\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043b\u044f \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043f\u0440\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0438 \u0434\u043e\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u0430 \u043b\u0438\u0448\u044c \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a \u043d\u0438\u043c \u0441 \u0446\u0435\u043b\u044c\u044e \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c performance (lazy loading).<\/p>\n<\/li>\n<li>\n<p>\u041c\u0435\u0436\u0434\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0441\u0432\u044f\u0437\u0438 (one-to-many, many-to-many \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435).<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0432 <code>UPDATE<\/code> \u043b\u0438\u0448\u044c \u0442\u0435 \u043f\u043e\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0432 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u043c\u0435\u043d\u044f\u043b\u0438, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0440\u0435\u0434\u043a\u043e \u0438 \u043d\u0430\u043c \u043d\u0435\u0442 \u0441\u043c\u044b\u0441\u043b\u0430 \u0433\u043e\u043d\u044f\u0442\u044c \u0438\u0445 \u043f\u043e \u0441\u0435\u0442\u0438 (\u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f <a href=\"https:\/\/www.baeldung.com\/spring-data-jpa-dynamicupdate\" rel=\"noopener noreferrer nofollow\">DynamicUpdate<\/a>).<\/p>\n<\/li>\n<\/ol>\n<blockquote>\n<p>\u0414\u0430 \u0438 \u0431\u0430\u043d\u0430\u043b\u044c\u043d\u043e \u0441\u0430\u043c \u043a\u043e\u0434 \u043f\u043e \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0443 \u0442\u043e\u0436\u0435 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u0435\u0439 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438 (\u0438 \u0434\u043e\u043c\u0435\u043d\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e).<\/p>\n<\/blockquote>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u0442\u0435 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043f\u0443\u043d\u043a\u0442\u043e\u0432, \u0442\u043e \u043f\u0440\u0438\u0434\u0435\u0442\u0435 \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e (\u0441\u044e\u0440\u043f\u0440\u0438\u0437!) \u043d\u0430\u043f\u0438\u0448\u0438\u0442\u0435 \u0441\u0432\u043e\u0439 Hibernate (\u0430 \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0435\u0433\u043e \u0441\u0438\u043b\u044c\u043d\u043e \u0443\u0440\u0435\u0437\u0430\u043d\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e).<\/p>\n<h2>\u0426\u0435\u043b\u0438 JOOQ \u0438 Hibernate<\/h2>\n<p>JOOQ \u0440\u0435\u0448\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043d\u0438\u0437\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0448\u0438\u0431\u043e\u043a \u0435\u0449\u0435 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438. \u0410 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043a\u043e\u0434\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u0440\u044f\u043c\u043e \u0438\u0437 \u0441\u0445\u0435\u043c\u044b \u0411\u0414, \u043f\u0440\u0438 \u0435\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438 \u043c\u044b \u0441\u0440\u0430\u0437\u0443 \u0443\u0432\u0438\u0434\u0438\u043c, \u0433\u0434\u0435 \u043a\u043e\u0434 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u0442\u044c (\u043e\u043d \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f).<\/p>\n<p>Hibernate \u0440\u0435\u0448\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0430 \u0434\u043e\u043c\u0435\u043d\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0432 \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u0443\u044e \u0411\u0414 \u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442 (\u0447\u0442\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0411\u0414 \u0438 \u0438\u0445 \u043c\u0430\u043f\u043f\u0438\u043d\u0433 \u043d\u0430 \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b).<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435\u0442 \u0441\u043c\u044b\u0441\u043b\u0430 \u0440\u0430\u0441\u0441\u0443\u0436\u0434\u0430\u0442\u044c \u043e \u0442\u043e\u043c, \u0447\u0442\u043e Hibernate \u0445\u0443\u0436\u0435, \u0438\u043b\u0438 JOOQ \u043b\u0443\u0447\u0448\u0435. \u042d\u0442\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u043d\u0443\u0436\u043d\u044b \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447. \u0415\u0441\u043b\u0438 \u0432\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0432 \u043f\u0430\u0440\u0430\u0434\u0438\u0433\u043c\u0435 Transaction Script, \u0442\u043e JOOQ, \u0431\u0435\u0437\u0443\u0441\u043b\u043e\u0432\u043d\u043e, \u0431\u0443\u0434\u0435\u0442 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u044b\u043c \u0432\u044b\u0431\u043e\u0440\u043e\u043c. \u041d\u043e \u0435\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u0442\u0442\u0435\u0440\u043d Domain Model, \u043d\u043e \u0432 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u0433\u043d\u0443\u0448\u0430\u0435\u0442\u0435\u0441\u044c Hibernate, \u0442\u043e \u0432\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u043e\u0437\u043d\u0430\u0442\u044c \u0440\u0430\u0434\u043e\u0441\u0442\u044c \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0430 \u0432 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f\u0445 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u0432. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0435\u0441\u043b\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0434\u0435\u043b\u044c \u043f\u043b\u0430\u0442\u0438\u0442 \u0432\u0430\u043c \u0437\u0430 \u0442\u043e, \u0447\u0442\u043e \u0432\u044b \u043f\u0438\u0448\u0438\u0442\u0435 \u0435\u043c\u0443 <em>yet another Hibernate killer<\/em>, \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432 \u043d\u0435\u0442. \u041d\u043e \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0435\u043c\u0443 \u043d\u0443\u0436\u043d\u0430 \u043e\u0442 \u0432\u0430\u0441 \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0430, \u0430 \u043d\u0435 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u044b\u0439 \u043a\u043e\u0434 \u0441 \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u043e\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0432 \u0411\u0414 \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e.<\/p>\n<p>\u041a\u0441\u0442\u0430\u0442\u0438, \u044f \u0441\u0447\u0438\u0442\u0430\u044e, \u0447\u0442\u043e \u0441\u0432\u044f\u0437\u043a\u0430 Hibernate + JOOQ \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u043a <a href=\"https:\/\/martinfowler.com\/bliki\/CQRS.html\" rel=\"noopener noreferrer nofollow\">CQRS<\/a>. \u0423 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 (\u0438\u043b\u0438 \u0435\u0433\u043e \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0447\u0430\u0441\u0442\u044c), \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u0442\u043e \u0435\u0441\u0442\u044c <code>CREATE\/UPDATE\/DELETE<\/code> \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438. \u0417\u0434\u0435\u0441\u044c Hibernate \u0431\u0443\u0434\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u043a\u0441\u0442\u0430\u0442\u0438. \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c query-\u0441\u0435\u0440\u0432\u0438\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0445\u043e\u0447\u0435\u0442 \u0447\u0438\u0442\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435. \u0422\u0443\u0442 JOOQ \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f. \u0421 \u043d\u0438\u043c \u0431\u0443\u0434\u0435\u0442 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043f\u0440\u043e\u0449\u0435 \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0442\u043e\u0447\u0435\u0447\u043d\u043e, \u0447\u0435\u043c \u0441 Hibernate.<\/p>\n<h2>\u0410 \u043a\u0430\u043a \u043d\u0430\u0441\u0447\u0435\u0442 DAO \u0432 JOOQ?<\/h2>\n<p>\u042d\u0442\u043e \u043f\u0440\u0430\u0432\u0434\u0430. JOOQ \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c DAO, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0442\u0438\u043f\u043e\u0432\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043f\u043e \u043f\u043e\u0438\u0441\u043a\u0443 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0432 \u0411\u0414. \u041c\u043e\u0436\u043d\u043e \u0434\u0430\u0436\u0435 \u0435\u0433\u043e \u043e\u0442\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0441\u0432\u043e\u0438\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438. \u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, JOOQ \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0447\u0435\u0440\u0435\u0437 \u0441\u0435\u0442\u0442\u0435\u0440\u044b, \u043f\u043e\u0434\u043e\u0431\u043d\u043e Hibernate, \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432 \u043c\u0435\u0442\u043e\u0434\u044b insert\/update \u0432 DAO. \u0427\u0435\u043c \u0432\u0430\u043c \u043d\u0435 Spring Data?<\/p>\n<p>\u0412 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u043a\u0435\u0439\u0441\u0430\u0445 \u044d\u0442\u043e \u0438 \u043f\u0440\u0430\u0432\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c. \u041d\u043e \u0432\u043e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u043e \u043c\u0430\u043b\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0442\u043e\u0433\u043e, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u0438\u0441\u0430\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u0432\u0440\u0443\u0447\u043d\u0443\u044e. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043f\u043e\u0445\u043e\u0436\u0438\u0435:<\/p>\n<ol>\n<li>\n<p>\u0412 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044f\u0445 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0441\u0432\u044f\u0437\u0435\u0439: \u043d\u0438 ManyToOne, \u043d\u0438 OneToMany. \u0422\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0438\u0437 \u0411\u0414. \u042d\u0442\u043e \u0441\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u0442\u0440\u0443\u0434\u043d\u044f\u0435\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043f\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u041d\u0435\u043b\u044c\u0437\u044f \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0438\u0445 \u0432 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u044e \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p>\u0422\u043e\u0442 \u0444\u0430\u043a\u0442, \u0447\u0442\u043e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 DAO, \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0432\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0445 \u043c\u0435\u043d\u044f\u0442\u044c \u043f\u043e \u0441\u0432\u043e\u0435\u043c\u0443 \u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u044e. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u043e\u043b\u0435 \u043d\u0430 Value Object, \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0432\u044f\u0437\u044c \u043d\u0430 \u0434\u0440\u0443\u0433\u0443\u044e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c, \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u043f\u043e\u043b\u044f \u0432 Embeddable \u0438 \u0442 \u0434. \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u0430\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0441\u043e\u0442\u0440\u0435\u0442 \u0432\u0430\u0448\u0438 \u0442\u0440\u0443\u0434\u044b. \u0414\u0430, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0430\u0447\u0435, \u043d\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043a\u0430\u0441\u0442\u043e\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u043e\u0436\u0435 \u043d\u0435 \u0431\u0435\u0437\u0433\u0440\u0430\u043d\u0438\u0447\u043d\u044b (\u0438 \u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u0442\u0430\u043a \u0443\u0434\u043e\u0431\u043d\u044b, \u043a\u0430\u043a \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434 \u0441\u0430\u043c\u043e\u043c\u0443).<\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u0430\u043a \u0447\u0442\u043e \u0437\u0434\u0435\u0441\u044c, \u0435\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u0443\u044e \u0434\u043e\u043c\u0435\u043d\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c, \u0432\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u0435\u0435 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e. \u0410 \u0431\u0435\u0437 Hibernate \u0432\u043e\u043f\u0440\u043e\u0441 \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0430 \u043b\u044f\u0436\u0435\u0442 \u0446\u0435\u043b\u0438\u043a\u043e\u043c \u043d\u0430 \u0432\u0430\u0448\u0438 \u043f\u043b\u0435\u0447\u0438. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0441 JOOQ \u0435\u0433\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u0438\u044f\u0442\u043d\u0435\u0435, \u0447\u0435\u043c \u0441 JDBI, \u043d\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0442\u0440\u0443\u0434\u043e\u0435\u043c\u043a\u0438\u043c.<\/p>\n<blockquote>\n<p>\u0414\u0430\u0436\u0435 \u0441\u0430\u043c Lukas Eder, \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u044c JOOQ, <a href=\"https:\/\/blog.jooq.org\/to-dao-or-not-to-dao\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0438\u0448\u0435\u0442 \u0432 \u0431\u043b\u043e\u0433\u0435<\/a>, \u0447\u0442\u043e DAO \u0431\u044b\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u044d\u0442\u043e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u0430 \u0432\u043e\u0432\u0441\u0435 \u043d\u0435 \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043e\u043d \u0432\u0441\u0435\u043c \u0441\u043e\u0432\u0435\u0442\u0443\u0435\u0442 \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c.<\/p>\n<\/blockquote>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e, \u0447\u0442\u043e \u0434\u043e\u0447\u0438\u0442\u0430\u043b\u0438 \u0441\u0442\u0430\u0442\u044c\u044e. \u042f \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u043e\u043a\u043b\u043e\u043d\u043d\u0438\u043a Hibernate \u0438 \u0441\u0447\u0438\u0442\u0430\u044e \u0435\u0433\u043e \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u043c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u043c. \u041d\u043e \u044f \u043d\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044e, \u0447\u0442\u043e \u043a\u043e\u043c\u0443-\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c JOOQ \u0443\u0434\u043e\u0431\u043d\u0435\u0435. \u0413\u043b\u0430\u0432\u043d\u0430\u044f \u043c\u044b\u0441\u043b\u044c \u043c\u043e\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e Hibernate \u0438 JOOQ \u2013 \u043d\u0435 \u0432\u0440\u0430\u0433\u0438. \u042d\u0442\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0432\u043f\u043e\u043b\u043d\u0435 \u043c\u043e\u0433\u0443\u0442 \u0441\u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u0436\u0435 \u0432 \u043e\u0434\u043d\u043e\u043c \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0435, \u0435\u0441\u043b\u0438 \u0432 \u044d\u0442\u043e\u043c \u0435\u0441\u0442\u044c \u0446\u0435\u043d\u043d\u043e\u0441\u0442\u044c. <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438\/\u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u044f \u043f\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044e, \u0431\u0443\u0434\u0443 \u0440\u0430\u0434 \u0438\u0445 \u043e\u0431\u0441\u0443\u0434\u0438\u0442\u044c. \u041f\u0440\u043e\u0434\u0443\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0432\u0430\u043c \u0434\u043d\u044f!<\/p>\n<h2>\u0421\u0441\u044b\u043b\u043a\u0438<\/h2>\n<ol>\n<li>\n<p><a href=\"https:\/\/jdbi.org\/jdbi2\/five_minute_intro\/\" rel=\"noopener noreferrer nofollow\">JDBI<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/martinfowler.com\/eaaCatalog\/transactionScript.html\" rel=\"noopener noreferrer nofollow\">Transaction Script<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/martinfowler.com\/eaaCatalog\/domainModel.html\" rel=\"noopener noreferrer nofollow\">Domain Model<\/a><\/p>\n<\/li>\n<li>\n<p>\u041c\u043e\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u2013 <a href=\"https:\/\/dev.to\/kirekov\/rich-domain-model-with-hibernate-445k\" rel=\"noopener noreferrer nofollow\">Rich Domain Model with Spring Boot and Hibernate<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/martinfowler.com\/eaaCatalog\/repository.html\" rel=\"noopener noreferrer nofollow\">Repository pattern<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/martinfowler.com\/bliki\/ValueObject.html\" rel=\"noopener noreferrer nofollow\">Value Object<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.baeldung.com\/jpa-embedded-embeddable\" rel=\"noopener noreferrer nofollow\">JPA Embedded<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.baeldung.com\/spring-data-jpa-dynamicupdate\" rel=\"noopener noreferrer nofollow\">JPA DynamicUpdate<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/martinfowler.com\/bliki\/CQRS.html\" rel=\"noopener noreferrer nofollow\">CQRS<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/blog.jooq.org\/to-dao-or-not-to-dao\/\" rel=\"noopener noreferrer nofollow\">Lukas Eder: To DAO or not to DAO<\/a><\/p>\n<\/li>\n<\/ol>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><\/p>\n<div class=\"tm-article-poll-container\"><!--[--><\/p>\n<div class=\"tm-article-poll tm-article-poll_variant-bordered\">\n<div class=\"tm-notice tm-notice_positive tm-article-poll__notice\"><!----><\/p>\n<div class=\"tm-notice__inner\"><!----><\/p>\n<div class=\"tm-notice__content\" data-test-id=\"notice-content\"><!--[--><span>\u0422\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u043e\u043f\u0440\u043e\u0441\u0435. <a rel=\"nofollow\" href=\"\/kek\/v1\/auth\/habrahabr\/?back=\/ru\/articles\/872562\/&#038;hl=ru\">\u0412\u043e\u0439\u0434\u0438\u0442\u0435<\/a>, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430.<\/span><!--]--><\/div>\n<\/div>\n<\/div>\n<p><!--[--><\/p>\n<div class=\"tm-article-poll__header\">\u0427\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u0443 \u0441\u0435\u0431\u044f \u043d\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0435?<\/div>\n<div class=\"tm-article-poll__answers\"><!--[--><\/p>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent tm-article-poll__answer-percent_winning\">46% <\/span><span class=\"tm-article-poll__answer-label\">JPA\/Hibernate<\/span><span class=\"tm-article-poll__answer-votes\">23<\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress tm-article-poll__answer-progress_winning\" style=\"width: 46%\"><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent\">20% <\/span><span class=\"tm-article-poll__answer-label\">JOOQ<\/span><span class=\"tm-article-poll__answer-votes\">10<\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress\" style=\"width: 20%\"><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent\">4% <\/span><span class=\"tm-article-poll__answer-label\">\u0418 \u0442\u043e, \u0438 \u0434\u0440\u0443\u0433\u043e\u0435 \u0432\u043c\u0435\u0441\u0442\u0435<\/span><span class=\"tm-article-poll__answer-votes\">2<\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress\" style=\"width: 4%\"><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent\">30% <\/span><span class=\"tm-article-poll__answer-label\">\u0414\u0440\u0443\u0433\u043e\u0435<\/span><span class=\"tm-article-poll__answer-votes\">15<\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress\" style=\"width: 30%\"><\/div>\n<\/div>\n<\/div>\n<p><!--]--><\/div>\n<div class=\"tm-article-poll__stats\"> \u041f\u0440\u043e\u0433\u043e\u043b\u043e\u0441\u043e\u0432\u0430\u043b\u0438 50 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439.   \u0412\u043e\u0437\u0434\u0435\u0440\u0436\u0430\u043b\u0438\u0441\u044c 6 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439. <\/div>\n<p><!--]--><\/div>\n<p><!--]--><\/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\/articles\/872562\/\"> https:\/\/habr.com\/ru\/articles\/872562\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u0433\u043e\u0434-\u043f\u043e\u043b\u0442\u043e\u0440\u0430 \u044f \u043d\u0430\u0442\u044b\u043a\u0430\u044e\u0441\u044c \u043d\u0430 \u0441\u0442\u0430\u0442\u044c\u0438 \u0438 \u0434\u043e\u043a\u043b\u0430\u0434\u044b (\u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432 \u0430\u043d\u0433\u043b\u043e\u044f\u0437\u044b\u0447\u043d\u043e\u043c \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0435) \u043e \u0442\u043e\u043c, \u0447\u0442\u043e JOOQ \u2013 \u044d\u0442\u043e \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0438 \u0431\u043e\u043b\u0435\u0435 \u043a\u0440\u0443\u0442\u0430\u044f \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0430 Hibernate. \u0422\u0435\u0437\u0438\u0441\u044b \u0437\u0432\u0443\u0447\u0430\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<ol>\n<li>\n<p>JOOQ \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u0430\u043c \u0432\u0441\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0432 compile time, \u0430 Hibernate \u2013 \u043d\u0435\u0442!<\/p>\n<\/li>\n<li>\n<p>\u0412 Hibernate \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u0435 \u0438 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u0430 \u0432 JOOQ \u0432\u0441\u0435 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e!<\/p>\n<\/li>\n<li>\n<p>\u0412 Hibernate \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u044b\u0435 \u0438 \u044d\u0442\u043e \u043f\u043b\u043e\u0445\u043e. \u0410 JOOQ \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u0441\u0435 entity \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u043c\u0438 (\u043f\u0440\u0438\u0432\u0435\u0442 \u0424\u041f)!<\/p>\n<\/li>\n<li>\n<p>\u0412 JOOQ \u043d\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u00ab\u043c\u0430\u0433\u0438\u0438\u00bb \u0441 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f\u043c\u0438!<\/p>\n<\/li>\n<\/ol>\n<p>\u0421\u043a\u0430\u0436\u0443 \u0441\u0440\u0430\u0437\u0443, \u0447\u0442\u043e \u044f \u0441\u0447\u0438\u0442\u0430\u044e JOOQ \u043e\u0442\u043b\u0438\u0447\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 (\u0438\u043c\u0435\u043d\u043d\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439, \u0430 \u043d\u0435 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u043c, \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 Hibernate). \u041e\u043d \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e \u0441\u0432\u043e\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u2013 \u0440\u0430\u0431\u043e\u0442\u043e\u0439 \u0441 SQL \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043b\u043e\u0432\u0438\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043e\u0448\u0438\u0431\u043e\u043a \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438.<\/p>\n<p>\u041d\u043e \u043a\u043e\u0433\u0434\u0430 \u044f \u0441\u043b\u044b\u0448\u0443 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442, \u0447\u0442\u043e \u0432\u0440\u0435\u043c\u044f Hibernate \u043f\u0440\u043e\u0448\u043b\u043e \u0438 \u043f\u043e\u0440\u0430 \u0432\u0441\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430 JOOQ, \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u044d\u0442\u043e \u0437\u0432\u0443\u0447\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u0442\u043e, \u0447\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0411\u0414 \u043f\u0440\u043e\u0448\u043b\u043e \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e NoSQL. \u0417\u0432\u0443\u0447\u0438\u0442 \u0441\u043c\u0435\u0448\u043d\u043e? \u041d\u043e \u043f\u043e \u043c\u0435\u0440\u043a\u0430\u043c \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0431\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u0432\u0447\u0435\u0440\u0430 \u0442\u0430\u043a\u0438\u0435 \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440\u044b \u0432\u0435\u043b\u0438\u0441\u044c \u0432\u043f\u043e\u043b\u043d\u0435 \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u043e.<\/p>\n<p>\u042f \u0434\u0443\u043c\u0430\u044e, \u0434\u0435\u043b\u043e \u043a\u0440\u043e\u0435\u0442\u0441\u044f \u0432 \u043d\u0435\u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0438 \u043a\u043e\u0440\u043d\u0435\u0432\u044b\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0435\u0448\u0430\u044e\u0442 \u044d\u0442\u0438 \u0434\u0432\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430. \u042d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435\u0439 \u044f \u0445\u043e\u0447\u0443 \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u043d\u0430 \u044d\u0442\u0438 \u0432\u043e\u043f\u0440\u043e\u0441\u044b. \u041c\u044b \u0441 \u0432\u0430\u043c\u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c:<\/p>\n<ol>\n<li>\n<p>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Transaction Script?<\/p>\n<\/li>\n<li>\n<p>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Domain Model?<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u043a\u0438\u0435 \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0440\u0435\u0448\u0430\u044e\u0442 Hibernate \u0438 JOOQ?<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443 \u043e\u0434\u0438\u043d \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0437\u0430\u043c\u0435\u043d\u043e\u0439 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0438 \u043a\u0430\u043a \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0441\u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c?<\/p>\n<\/li>\n<\/ol>\n<figure class=\"\">\n<div><figcaption>\u041c\u0435\u043c\u043d\u044b\u0439 \u043a\u0430\u0432\u0435\u0440 \u043a \u0441\u0442\u0430\u0442\u044c\u0435<\/figcaption><\/div>\n<\/figure>\n<h2>Transaction Script<\/h2>\n<p>\u0421\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438 \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0411\u0414 \u2013 \u043f\u0430\u0442\u0442\u0435\u0440\u043d <a href=\"https:\/\/martinfowler.com\/eaaCatalog\/transactionScript.html\" rel=\"noopener noreferrer nofollow\">Transaction Script<\/a>. \u0415\u0441\u043b\u0438 \u043a\u0440\u0430\u0442\u043a\u043e, \u0432\u044b \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0443\u0435\u0442\u0435 \u0432\u0441\u044e \u0432\u0430\u0448\u0443 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443 \u0432 \u0432\u0438\u0434\u0435 \u043d\u0430\u0431\u043e\u0440\u0430 SQL-\u043a\u043e\u043c\u0430\u043d\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u0442\u0435 \u0432 \u043e\u0434\u043d\u0443 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e. \u0427\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u043a\u0430\u043a\u0443\u044e-\u0442\u043e \u0431\u0438\u0437\u043d\u0435\u0441-\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e, \u0438 \u043e\u043d \u0436\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d \u043e\u0434\u043d\u043e\u0439 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0435\u0439.<\/p>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043c\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043f\u0438\u043a\u0435\u0440\u0430\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0441\u0432\u043e\u0439 \u0434\u043e\u043a\u043b\u0430\u0434 \u043d\u0430 \u043a\u043e\u043d\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u044e (\u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u0443\u0434\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0434\u043e\u043a\u043b\u0430\u0434\u0430). \u0415\u0441\u043b\u0438 \u043c\u044b \u0441\u043b\u0435\u0434\u0443\u0435\u043c \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0443 Transaction Script, \u0442\u043e \u043c\u0435\u0442\u043e\u0434 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0434\u043e\u043a\u043b\u0430\u0434\u0430 \u043d\u0430 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a (\u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0434\u043b\u044f SQL \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e <a href=\"https:\/\/jdbi.org\/jdbi2\/five_minute_intro\/\" rel=\"noopener noreferrer nofollow\">JDBI<\/a>):<\/p>\n<pre><code class=\"java\">@Service @RequiredArgsConstructor public class TalkService {     private final Jdbi jdbi;      public TalkSubmittedResult submitTalk(Long speakerId, String title) {         var talkId = jdbi.inTransaction(handle -&gt; {             \/\/ \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u044b\u0445 \u0434\u043e\u043a\u043b\u0430\u0434\u043e\u0432 \u0443 \u0441\u043f\u0438\u043a\u0435\u0440\u0430             var acceptedTalksCount =                 handle.select(\"SELECT count(*) FROM talk WHERE speaker_id = :id AND status = 'ACCEPTED'\")                     .bind(\"id\", speakerId)                     .mapTo(Long.class)                     .one();             \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u0441\u043f\u0438\u043a\u0435\u0440 \u043e\u043f\u044b\u0442\u043d\u044b\u043c             var experienced = acceptedTalksCount &gt;= 10;             \/\/ \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u043e\u043a\u043b\u0430\u0434\u043e\u0432             var maxSubmittedTalksCount = experienced ? 5 : 3;             var submittedTalksCount =                 handle.select(\"SELECT count(*) FROM talk WHERE speaker_id = :id AND status = 'SUBMITTED'\")                     .bind(\"id\", speakerId)                     .mapTo(Long.class)                     .one();             \/\/ \u0415\u0441\u043b\u0438 \u043f\u0440\u0435\u0432\u044b\u0448\u0435\u043d\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0434\u043e\u043a\u043b\u0430\u0434\u043e\u0432 \u043d\u0430 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u0438, \u043a\u0438\u0434\u0430\u0435\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435             if (submittedTalksCount &gt;= maxSubmittedTalksCount) {                 throw new CannotSubmitTalkException(\"Submitted talks count is maximum: \" + maxSubmittedTalksCount);             }             return handle.createUpdate(                     \"\"\"                         INSERT INTO talk (speaker_id, status, title)                         VALUES (:id, 'SUBMITTED', :title)                         \"\"\"                 ).bind(\"id\", speakerId)                        .bind(\"title\", title)                        .executeAndReturnGeneratedKeys(\"id\")                        .mapTo(Long.class)                        .one();         });         return new TalkSubmittedResult(talkId);     }   }<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<ol>\n<li>\n<p>\u0421\u0447\u0438\u0442\u0430\u0435\u043c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043f\u0438\u043a\u0435\u0440 \u0443\u0436\u0435 \u043f\u043e\u0434\u0430\u043b \u0434\u043e\u043a\u043b\u0430\u0434\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c, \u043d\u0435 \u043f\u0440\u0435\u0432\u044b\u0448\u0435\u043d\u043e \u043b\u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u043e\u043a\u043b\u0430\u0434\u043e\u0432 \u043d\u0430 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u043e\u043a, \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u0434\u043e\u043a\u043b\u0430\u0434 \u0432 \u0441\u0442\u0430\u0442\u0443\u0441\u0435 <code>SUBMITTED<\/code>.<\/p>\n<\/li>\n<\/ol>\n<blockquote>\n<p>\u0417\u0434\u0435\u0441\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u0430 \u0433\u043e\u043d\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u043e \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u043f\u043e\u0432\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u043e\u0441\u0442\u0440\u044f\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 pessimistic \u0438\u043b\u0438 optimistic locking.<\/p>\n<\/blockquote>\n<p>\u041f\u043b\u044e\u0441\u044b \u0443 \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435:<\/p>\n<ol>\n<li>\n<p>SQL, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0441\u044f, \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u0435\u043d \u0438 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c. \u0415\u0433\u043e \u043b\u0435\u0433\u043a\u043e \u043f\u043e\u0434\u0442\u044e\u043d\u0438\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c performance \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u0442\u044c \u0438\u0437 \u0411\u0414 \u043b\u0438\u0448\u044c \u043d\u0443\u0436\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<\/li>\n<li>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f JOOQ, \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0449\u0435, \u043a\u043e\u0440\u043e\u0447\u0435, \u0434\u0430 \u0435\u0449\u0435 \u0438 \u0441\u043e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0435\u0439!<\/p>\n<\/li>\n<\/ol>\n<p>\u041c\u0438\u043d\u0443\u0441\u044b \u0436\u0435 \u0442\u0430\u043a\u0438\u0435:<\/p>\n<ol>\n<li>\n<p>\u041d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e unit-\u0442\u0435\u0441\u0442\u043e\u0432. \u041e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0443\u0436\u043d\u044b \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 (\u0438 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u043d\u043e\u0433\u043e).<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0434\u043e\u043c\u0435\u043d \u0441\u043b\u043e\u0436\u043d\u044b\u0439, \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442 \u043a \u0441\u043f\u0430\u0433\u0435\u0442\u0442\u0438-\u043a\u043e\u0434\u0443.<\/p>\n<\/li>\n<li>\n<p>\u0420\u0438\u0441\u043a \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u044b\u043c \u0431\u0430\u0433\u0430\u043c \u043f\u0440\u0438 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u044b.<\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0432\u0430\u043b\u0438\u0434\u0435\u043d \u0438 \u043b\u043e\u0433\u0438\u0447\u0435\u043d, \u0435\u0441\u043b\u0438 \u0432 \u0432\u0430\u0448\u0435\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0442\u0430\u043a\u0436\u0435 \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u043d\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442 \u0443\u0441\u043b\u043e\u0436\u043d\u0435\u043d\u0438\u044f. \u041d\u043e \u0447\u0430\u0441\u0442\u043e \u0434\u043e\u043c\u0435\u043d\u044b \u0431\u044b\u0432\u0430\u044e\u0442 \u043a\u0440\u0443\u043f\u043d\u0435\u0435. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0430.<\/p>\n<h2>\u0414\u043e\u043c\u0435\u043d\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c<\/h2>\n<p>\u0418\u0434\u0435\u044f \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 <a href=\"https:\/\/martinfowler.com\/eaaCatalog\/domainModel.html\" rel=\"noopener noreferrer nofollow\">Domain Model<\/a> \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u044b \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0437\u0430\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u043c \u043d\u0430\u0448\u0443 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043d\u0430 SQL-\u043a\u043e\u043c\u0430\u043d\u0434\u044b. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e, \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0434\u043e\u043c\u0435\u043d\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b (\u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 Java, \u043a\u043b\u0430\u0441\u0441\u044b), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0438 \u0445\u0440\u0430\u043d\u044f\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u0434\u043e\u043c\u0435\u043d\u043d\u044b\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044f\u0445.<\/p>\n<blockquote>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043e \u0440\u0430\u0437\u043d\u0438\u0446\u0435 \u0430\u043d\u0435\u043c\u0438\u0447\u043d\u043e\u0439 \u0438 \u0431\u043e\u0433\u0430\u0442\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u044f\u0445. \u0415\u0441\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u044f \u043f\u0438\u0441\u0430\u043b \u043e\u0431 \u044d\u0442\u043e\u043c <a href=\"https:\/\/dev.to\/kirekov\/rich-domain-model-with-hibernate-445k\" rel=\"noopener noreferrer nofollow\">\u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e<\/a>.<\/p>\n<\/blockquote>\n<p>\u0411\u0438\u0437\u043d\u0435\u0441-\u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 (\u0441\u0435\u0440\u0432\u0438\u0441\u044b) \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0438 \u043d\u0435 \u0437\u0430\u0432\u044f\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432 \u0411\u0414.<\/p>\n<blockquote>\n<p>\u042f\u0441\u043d\u043e\u0435 \u0434\u0435\u043b\u043e, \u0447\u0442\u043e \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0443 \u043d\u0430\u0441 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043c\u0438\u043a\u0441 \u0438\u0437 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u0434\u043e\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438 \u0438 \u043f\u0440\u044f\u043c\u044b\u043c\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438 \u0432 \u0411\u0414 \u0441 \u0446\u0435\u043b\u044c\u044e \u0441\u043e\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0439 \u043f\u043e performance. \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u0445\u0440\u0435\u0441\u0442\u043e\u043c\u0430\u0442\u0438\u0439\u043d\u043e\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435 \u043f\u0440\u0438 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0438 Domain Model, \u043a\u043e\u0433\u0434\u0430 \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u044f\u0446\u0438\u044f \u0438 \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u044f \u043d\u0435 \u043d\u0430\u0440\u0443\u0448\u0430\u044e\u0442\u0441\u044f.<\/p>\n<\/blockquote>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u0440\u0435\u0447\u044c \u0438\u0434\u0435\u0442 \u043e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044f\u0445 <code>Speaker<\/code> \u0438 <code>Talk<\/code>, \u043a\u0430\u043a \u0431\u044b\u043b\u043e \u0440\u0430\u043d\u0435\u0435, \u0434\u043e\u043c\u0435\u043d\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"java\">@AllArgsConstructor public class Speaker {     private Long id;     private String firstName;     private String lastName;     private List&lt;Talk&gt; talks;      public Talk submitTalk(String title) {         boolean experienced = countTalksByStatus(Status.ACCEPTED) &gt;= 10;         int maxSubmittedTalksCount = experienced ? 3 : 5;         if (countTalksByStatus(Status.SUBMITTED) &gt;= maxSubmittedTalksCount) {             throw new CannotSubmitTalkException(               \"Submitted talks count is maximum: \" + maxSubmittedTalksCount);         }         Talk talk = Talk.newTalk(this, Status.SUBMITTED, title);         talks.add(talk);         return talk;     }        public void acceptTalk(int talkNumber) {         Talk talk = talkByNumber(talkNumber);         talk.setStatus(status -&gt; {             if (!status.equals(Status.SUBMITTED)) {                 throw new CannotAcceptTalkException(\"\");             }             return Status.ACCEPTED;         });     }      public void rejectTalk(int talkNumber) {         Talk talk = talkByNumber(talkNumber);         talk.setStatus(status -&gt; {             if (!status.equals(Status.SUBMITTED)) {                 throw new CannotRejectTalkException(\"\");             }             return Status.REJECTED;         });     }      private Talk talkByNumber(int number) {         return talks.stream().filter(t -&gt; Objects.equals(t.getNumber(), number)).findFirst()             .orElseThrow();     }      private long countTalksByStatus(Talk.Status status) {         return talks.stream().filter(t -&gt; t.getStatus().equals(status)).count();     } }  @AllArgsConstructor public class Talk {     private Long id;     private Speaker speaker;     private Status status;     private String title;     private int talkNumber;      void setStatus(Function&lt;Status, Status&gt; fnStatus) {         this.status = fnStatus.apply(this.status);     }        public enum Status {         SUBMITTED, ACCEPTED, REJECTED     } }<\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u043e\u0442\u043a\u0443\u0434\u0430-\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0438 \u043a\u0443\u0434\u0430-\u0442\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0434\u043e\u043c\u0435\u043d\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <a href=\"https:\/\/martinfowler.com\/eaaCatalog\/repository.html\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439<\/a>. \u042d\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0430\u0433\u0440\u0435\u0433\u0430\u0442, \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043d\u0430\u0434 \u043d\u0438\u043c \u043a\u0430\u043a\u0438\u0445-\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0441\u0430\u043c\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u043d\u0430\u0441 \u043d\u0435 \u0432\u043e\u043b\u043d\u0443\u0435\u0442, \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043b\u0438\u0448\u044c \u0435\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441.<\/p>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u0443 \u043d\u0430\u0441 \u0442\u0430\u043a\u043e\u0439 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439:<\/p>\n<pre><code class=\"java\">public interface SpeakerRepository {     Speaker findById(Long id);     void save(Speaker speaker); }<\/code><\/pre>\n<p>\u0422\u043e\u0433\u0434\u0430 \u0441\u0435\u0440\u0432\u0438\u0441 \u043f\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 <code>submitTalk<\/code> \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"java\">@Service @RequiredArgsConstructor public class SpeakerService {     private final SpeakerRepository repo;      public TalkSubmittedResult submitTalk(Long speakerId, String title) {         Speaker speaker = repo.findById(speakerId);         Talk talk = speaker.submitTalk(title);         repo.save(speaker);         return new TalkSubmittedResult(talk.getId());     } }<\/code><\/pre>\n<p>\u041f\u043b\u044e\u0441\u044b \u0434\u043e\u043c\u0435\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0442\u0430\u043a\u0438\u0435:<\/p>\n<ol>\n<li>\n<p>\u0414\u043e\u043c\u0435\u043d\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043e\u0442\u0432\u044f\u0437\u0430\u043d\u044b \u043e\u0442 \u0434\u0435\u0442\u0430\u043b\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 (\u0442\u043e \u0435\u0441\u0442\u044c \u043e\u0442 \u0411\u0414). \u0417\u043d\u0430\u0447\u0438\u0442, \u0438\u0445 \u043b\u0435\u0433\u043a\u043e \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u044b\u043c\u0438 unit-\u0442\u0435\u0441\u0442\u0430\u043c\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0411\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0430 \u0441\u043a\u043e\u043d\u0446\u0435\u043d\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435, \u0432 \u0434\u043e\u043c\u0435\u043d\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u0445. \u0413\u043e\u0440\u0430\u0437\u0434\u043e \u043c\u0435\u043d\u044c\u0448\u0438\u0439 \u0440\u0438\u0441\u043a \u0440\u0430\u0441\u043f\u043e\u043b\u0437\u0430\u043d\u0438\u044f \u043b\u043e\u0433\u0438\u043a\u0438 \u043f\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e, \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 Transaction Script.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u0438 \u0434\u043e\u043c\u0435\u043d\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0438\u043c\u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u044b\u043c\u0438, \u0447\u0442\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043d\u0438\u043c\u0438 (\u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u0445 \u0432 \u043b\u044e\u0431\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u0438 \u043d\u0435 \u0431\u043e\u044f\u0442\u0441\u044f, \u0447\u0442\u043e \u043e\u043d \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442 \u0438\u0445 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435).<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043b\u044f \u0432 \u0434\u043e\u043c\u0435\u043d\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u0445 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430 <a href=\"https:\/\/martinfowler.com\/bliki\/ValueObject.html\" rel=\"noopener noreferrer nofollow\">Value Objects<\/a>, \u0447\u0442\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0432\u044b\u0441\u0438\u0442 \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u044c, \u043d\u043e \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0430\u043b\u0438\u0434\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u043b\u0435\u0439 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0438\u0445 \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u0438\u044f (\u043d\u0435\u043b\u044c\u0437\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c Value Object \u0441 \u043d\u0435\u0432\u0430\u043b\u0438\u0434\u043d\u044b\u043c \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u043e\u043c).<\/p>\n<\/li>\n<\/ol>\n<p>\u041a\u043e\u0440\u043e\u0447\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, \u043e\u0434\u043d\u0438 \u0441\u043f\u043b\u043e\u0448\u043d\u044b\u0435 \u043f\u043b\u044e\u0441\u044b. \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u0435\u0441\u0442\u044c \u043e\u0434\u043d\u0430 \u0432\u0430\u0436\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u0447\u0442\u043e \u0432 \u043a\u043d\u0438\u0433\u0430\u0445 \u043f\u043e Domain Driven Design, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u0438 \u043f\u0440\u043e\u0434\u0432\u0438\u0433\u0430\u0435\u0442\u0441\u044f Domain Model, \u044d\u0442\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043b\u0438\u0431\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442\u0441\u044f, \u043b\u0438\u0431\u043e \u0435\u0435 \u043a\u0430\u0441\u0430\u044e\u0442\u0441\u044f \u0432\u0441\u043a\u043e\u043b\u044c\u0437.<\/p>\n<p>\u0417\u0432\u0443\u0447\u0438\u0442 \u043e\u043d\u0430 \u0442\u0430\u043a: <strong><em>\u0430 \u043a\u0430\u043a \u0434\u043e\u043c\u0435\u043d\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u0411\u0414, \u0430 \u043f\u043e\u0442\u043e\u043c \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0442\u043d\u043e? <\/em><\/strong>\u0418\u043d\u0430\u0447\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, \u043a\u0430\u043a \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f?<\/p>\n<p>\u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0441\u0435\u0439\u0447\u0430\u0441 \u043e\u0442\u0432\u0435\u0442 \u043e\u0447\u0435\u0432\u0438\u0434\u0435\u043d. \u0412\u043e\u0437\u044c\u043c\u0438 Hibernate (\u0430 \u0435\u0449\u0435 \u043b\u0443\u0447\u0448\u0435, Spring Data JPA) \u0438 \u043d\u0435 \u043c\u0443\u0447\u0430\u0439\u0441\u044f. \u041d\u043e \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c,<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-444623","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/444623","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=444623"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/444623\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=444623"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=444623"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=444623"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}