{"id":332986,"date":"2022-05-11T09:00:53","date_gmt":"2022-05-11T09:00:53","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=332986"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=332986","title":{"rendered":"<span>\u041f\u0438\u0448\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 JetBrains Exposed<\/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<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/d8b\/db1\/b87\/d8bdb1b87aa46ae7f77ef43ea60f07e4.jpg\" width=\"780\" height=\"440\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d8b\/db1\/b87\/d8bdb1b87aa46ae7f77ef43ea60f07e4.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041f\u0440\u0438 \u0432\u0441\u0451\u043c \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u0438\u0438 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u043e\u0439, \u0441\u0442\u043e\u044f\u0449\u0438\u0445 \u0438 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u044e\u0449\u0438\u0445\u0441\u044f \u043d\u0435 \u0442\u0430\u043a \u0443\u0436 \u0438 \u043c\u043d\u043e\u0433\u043e. \u0418 \u0435\u0441\u043b\u0438 \u043f\u0440\u043e Hibernate \u0437\u043d\u0430\u044e\u0442 \u0432\u0441\u0435, \u0430 \u043f\u0440\u043e JOOQ \u0437\u043d\u0430\u044e\u0442 \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u0438\u0435, \u0442\u043e \u0441\u043b\u0430\u0431\u0430\u044f \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u044c Exposed \u0441\u043a\u043e\u0440\u0435\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u0441 \u0435\u0433\u043e \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439 \u043d\u0430 Kotlin. \u0415\u0441\u043b\u0438 \u0412\u044b \u0442\u043e\u043b\u044c\u043a\u043e-\u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u0448\u043b\u0438 \u0432 Kotlin \u0438\u0437 Java, \u0412\u0430\u043c \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u044b\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b, \u0437\u0430\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u0432 Exposed (\u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043b\u044f\u043c\u0431\u0434\u0430\u043c\u0438 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438-\u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f\u043c\u0438, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443) \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0434\u0438\u0447\u044c\u044e, \u043d\u043e \u043f\u0443\u0433\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u0441\u0442\u043e\u0438\u0442: \u0447\u0435\u043c \u0434\u0430\u043b\u044c\u0448\u0435 \u0412\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u043e\u0441\u0432\u0430\u0438\u0432\u0430\u0442\u044c Kotlin, \u0442\u0435\u043c \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u0435\u0435 \u0434\u043b\u044f \u0412\u0430\u0441 \u0431\u0443\u0434\u0443\u0442 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 Exposed.<\/p>\n<p>\u041a\u0430\u043a\u043e\u0435-\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0437\u0430\u0434 \u0437\u0434\u0435\u0441\u044c \u0443\u0436\u0435 \u0431\u044b\u043b\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u0440\u043e Exposed, \u043e\u0442 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 Otus, \u043d\u043e \u0441 \u0442\u0435\u0445 \u043f\u043e\u0440 \u043f\u0440\u043e\u0448\u043b\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0433\u043e\u0434\u0430 \u0438 \u043c\u043d\u043e\u0433\u0438\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u0441\u0432\u0435\u0436\u0438\u0442\u044c &#8212; \u0434\u0430\u0436\u0435 \u043f\u043e\u043a\u0430 \u044f \u043f\u0438\u0441\u0430\u043b \u044d\u0442\u0443 \u0441\u0442\u0430\u0442\u044c\u044e, \u043c\u043d\u043e\u0433\u043e\u0435 \u043f\u043e\u043c\u0435\u043d\u044f\u043b\u043e\u0441\u044c!<\/p>\n<h2>\u0418\u0442\u0430\u043a, \u043f\u043e\u0447\u0435\u043c\u0443 Exposed?<\/h2>\n<p>\u0412\u043e\u043e\u0431\u0449\u0435, \u0442\u0435\u043c\u0430 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0432\u043d\u0435\u0448\u043d\u0438\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430\u043c, \u043a\u043e\u0438\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438 \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0435\u0441\u044c\u043c\u0430 \u0434\u0438\u0441\u043a\u0443\u0441\u0441\u0438\u043e\u043d\u043d\u043e\u0439 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432. \u0423\u0433\u043e\u0434\u0438\u0442\u044c \u0441 \u0432\u044b\u0431\u043e\u0440\u043e\u043c \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u0431\u044b\u0432\u0430\u0435\u0442 \u0442\u044f\u0436\u0435\u043b\u043e \u0434\u0430\u0436\u0435 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b &#8212; \u0447\u0442\u043e \u0443\u0436 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043e \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0435 \u0432 \u0446\u0435\u043b\u043e\u043c. \u0412 \u0438\u0434\u0435\u0430\u043b\u0435, \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435 \u0436\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432 \u0431\u0430\u0437\u0443 \u043d\u0430 \u0441\u0432\u043e\u0435\u0439 \u043b\u044e\u0431\u0438\u043c\u043e\u0439 \u0434\u0436\u0430\u0432\u0435 \u0438\u043b\u0438 \u043a\u043e\u0442\u043b\u0438\u043d\u0435, \u043d\u043e \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 SQL, \u0438 \u0437\u0434\u0435\u0441\u044c \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 &#8212; \u0432 \u043a\u0430\u043a\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0451\u0442 \u0433\u0440\u0430\u043d\u0438\u0446\u0430 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u043e\u0442 Java \/ Kotlin \u0432 SQL \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e? \u041e\u0434\u043d\u0430 \u043a\u0440\u0430\u0439\u043d\u043e\u0441\u0442\u044c &#8212; Hibernate, c \u0435\u0433\u043e \u043f\u043e\u043b\u043d\u043e\u0439 \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439 \u043d\u0430 \u041e\u041e\u041f \u0438 \u0432\u044b\u0442\u0435\u043a\u0430\u044e\u0449\u0438\u043c\u0438 \u043e\u0442\u0441\u044e\u0434\u0430 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f, \u0434\u0440\u0443\u0433\u0430\u044f &#8212; JDBC, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0448\u043b\u0430 \u0432 1997 \u0433\u043e\u0434\u0443, \u043d\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u043b\u0430\u0441\u044c \u0441 2017 \u0433\u043e\u0434\u0430 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0445 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u0430\u0445. \u0412\u0441\u0435 \u043a\u043e\u043c\u043f\u0440\u043e\u043c\u0438\u0441\u0441\u043d\u044b\u0435 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0438 \u0432\u0440\u043e\u0434\u0435 JOOQ, QueryDSL \u0438 Speedment \u043f\u044b\u0442\u0430\u044e\u0442\u0441\u044f \u0441\u0440\u0430\u0441\u0442\u0438\u0442\u044c \u041e\u041e\u041f \u0438 \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0447\u0435\u0440\u0435\u0437 \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0441\u0432\u043e\u0438 API. \u0418, \u043a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u043f\u043e \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044e \u0438 \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u044e Exposed, \u043f\u043e\u043f\u044b\u0442\u043a\u0438 \u044d\u0442\u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044e\u0442\u0441\u044f.<\/p>\n<h2>\u0414\u043e\u0440\u043e\u0436\u043d\u0430\u044f \u043a\u0430\u0440\u0442\u0430 \u043f\u043e\u0441\u0442\u0430.<\/h2>\n<p>\u0418\u0442\u0430\u043a, \u0442\u043e \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043f\u043e\u0441\u0442\u0430?<\/p>\n<ol>\n<li>\n<p>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043c \u043f\u0440\u043e\u0435\u043a\u0442.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043c \u0432\u0441\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e: \u0431\u0438\u0437\u043d\u0435\u0441-\u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, API, \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<li>\n<p>\u041e\u043f\u0438\u0448\u0435\u043c \u043c\u0430\u043f\u0438\u043d\u0433 \u043c\u0435\u0436\u0434\u0443 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u044b.<\/p>\n<\/li>\n<\/ol>\n<p>\u042d\u0442\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0412\u044b \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b\u0438 \u043d\u043e\u0432\u044b\u0439 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u043d\u0430 \u0432\u043a\u0443\u0441. \u0412 \u043a\u043e\u043d\u0446\u0435 \u043f\u043e\u0441\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442, \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e.<\/p>\n<h2>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a.<\/h2>\n<p>\u0415\u0449\u0451 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0433\u043e\u0434 \u043d\u0430\u0437\u0430\u0434, \u043d\u0430\u043c \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0446\u0435\u043b\u044b\u0439 \u0432\u043e\u0440\u043e\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0438 \u043f\u0438\u0441\u0430\u0442\u044c \u0446\u0435\u043b\u0443\u044e \u044d\u0442\u0430\u0436\u0435\u0440\u043a\u0443 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a. \u0417\u0430 \u0433\u043e\u0434 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0430 \u043b\u043e\u0433\u0438\u0447\u043d\u0430\u044f \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u044f \u0434\u043e \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u043e\u0433\u043e \u0441\u0442\u0430\u0440\u0442\u0435\u0440\u0430 \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Exposed \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043e\u0434\u0438\u043d \u0438\u043c\u043f\u043e\u0440\u0442:<\/p>\n<pre><code>implementation(\"org.jetbrains.exposed:exposed-spring-boot-starter:0.38.2\")<\/code><\/pre>\n<p>\u0412\u0441\u0451. Exposed \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0451\u043d \u0438 \u0433\u043e\u0442\u043e\u0432 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b.<\/p>\n<p>\u0414\u0430, \u0440\u0430\u043d\u044c\u0448\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u043b\u0438 \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 -> \u043f\u043e\u0442\u043e\u043c \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043b\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438\u0437 \u043a\u043e\u043d\u0444\u0438\u0433\u043e\u0432 \u0421\u043f\u0440\u0438\u043d\u0433\u0430 -> \u0442\u0435\u043f\u0435\u0440\u044c \u044d\u0442\u043e \u0432\u0441\u0451 \u0432 \u0441\u0442\u0430\u0440\u0442\u0435\u0440\u0435. \u0420\u0430\u043d\u044c\u0448\u0435, \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043f\u0440\u0438\u043d\u0433\u043e\u0432\u0443\u044e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e Transactional, \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 &#8212; \u0442\u0435\u043f\u0435\u0440\u044c \u044d\u0442\u043e \u0432\u0441\u0451 \u0432 \u0441\u0442\u0430\u0440\u0442\u0435\u0440\u0435. \u0412 \u043e\u0431\u0449\u0435\u043c, \u0447\u0443\u0432\u0441\u0442\u0432\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 Jetbrains. \u0414\u0430, \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0430\u0442 \u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 &#171;\u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438&#187;, \u0438 \u0442\u0430\u043a\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043f\u043e\u043a\u0430 \u0432\u0441\u0451-\u0442\u0430\u043a\u0438 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0437\u0430\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e, \u043d\u043e, \u0441\u0443\u0434\u044f \u043f\u043e \u0442\u0435\u043d\u0434\u0435\u043d\u0446\u0438\u0438, \u043d\u0430\u0434\u043e\u0431\u043d\u043e\u0441\u0442\u044c \u0432 \u0441\u043a\u043e\u0440\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u0440\u043e\u043f\u0430\u0434\u0451\u0442 \u0438 \u0432 \u044d\u0442\u043e\u043c.<\/p>\n<p>\u0418\u0434\u0451\u043c \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<h2>\u0413\u043e\u0442\u043e\u0432\u0438\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445.<\/h2>\n<p>\u041b\u044e\u0431\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u0441 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439. \u0421 \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0447\u043d\u0451\u043c \u0438 \u043c\u044b. \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f c \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u0430\u044f:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/410\/e2d\/681\/410e2d681844055e2a97719bf2d5d5fb.png\" alt=\"\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0434\u0430\u043d\u043d\u044bx\" title=\"\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0434\u0430\u043d\u043d\u044bx\" width=\"583\" height=\"303\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/410\/e2d\/681\/410e2d681844055e2a97719bf2d5d5fb.png\"\/><figcaption>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0434\u0430\u043d\u043d\u044bx<\/figcaption><\/figure>\n<h4>\u0411\u0438\u0437\u043d\u0435\u0441-\u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c.<\/h4>\n<pre><code class=\"kotlin\">data class User(       val id: UUID? = null,       val name: String? = null,       val contacts: List&lt;Contact>? = null )  data class Contact(     val id: UUID? = null,     val type: ContactType,     val value: String? = null,     val userId: UUID )  enum class ContactType {     PHONE, EMAIL }<\/code><\/pre>\n<h4>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 (\u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f).<\/h4>\n<pre><code class=\"sql\">create table users ( id   uuid default gen_random_uuid() primary key,     name varchar(512) );  create table contacts (     id      uuid default gen_random_uuid() primary key,     type    varchar(128) not null,     value   varchar(256),     user_id uuid         constraint contacts_user_id_fkey references users );<\/code><\/pre>\n<p>\u042d\u0442\u0438 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u043a\u043e\u043d\u0446\u0430\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0418\u0445 \u0431\u0443\u0434\u0435\u0442 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0442\u044c Table API (\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u043d\u0430\u044f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c), \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 Kotlin.<\/p>\n<h4>Table API (\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u043d\u044b\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438).<\/h4>\n<pre><code class=\"kotlin\">object UserTable : IdTable&lt;UUID>(\"users\") {   override val id = uuid(\"id\").entityId()       val name = varchar(\"name\", 512).nullable() }  object ContactTable : IdTable&lt;UUID>(\"contacts\") {     override val id = ContactEntity.uuid(\"id\").entityId()     val type = varchar(\"type\", 128)     val value = varchar(\"value\", 256).nullable()     val userId = reference(\"user_id\", UserEntity) }<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u0435.<\/p>\n<p>\u041d\u0435\u0441\u043e\u043c\u043d\u0435\u043d\u043d\u044b\u0439 \u043f\u043b\u044e\u0441 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u043d\u044b\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u0438\u0437 \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d\u043e\u0432 \u0432\u043d\u0435 \u043e\u0440\u0431\u0438\u0442\u044b Spring \u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u0432 \u043b\u044e\u0431\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043d\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u044f\u0441\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438 Spring &#8212; \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043d\u0430\u0448\u0438 \u043c\u0430\u043f\u0435\u0440\u044b \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438 Spring, \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u043e\u0432\u0441\u044e \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c API Exposed.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435, \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 Table API Exposed \u043d\u0435 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043a\u0430\u043a \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 JOOQ &#8212; \u0438 \u044d\u0442\u043e \u0442\u043e\u0436\u0435 \u043d\u0435\u0441\u043e\u043c\u043d\u0435\u043d\u043d\u044b\u0439 \u043f\u043b\u044e\u0441. \u0412\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0435 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u043d\u0443\u044e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\u0435 \u0441 \u043d\u0435\u0439. \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0412\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0412\u0430\u0448\u0443 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u043e\u0442 <code>org.jetbrains.exposed.sql.Table<\/code>.<\/p>\n<p>\u0423 <code>Table<\/code> \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a <code>IdTable<\/code>, \u0430 \u0443 \u043d\u0435\u0433\u043e &#8212; \u0435\u0449\u0451 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u0434\u0430\u044e\u0442 \u0442\u0438\u043f <code>id<\/code> \u0432 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u043c \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/413\/afe\/d29\/413afed29de6f6d96958d6f970316158.png\" alt=\"Table, \u0435\u0433\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u0438 \u0438 \u0432\u043d\u0443\u043a\u0438\" title=\"Table, \u0435\u0433\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u0438 \u0438 \u0432\u043d\u0443\u043a\u0438\" width=\"563\" height=\"473\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/413\/afe\/d29\/413afed29de6f6d96958d6f970316158.png\"\/><figcaption>Table, \u0435\u0433\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u0438 \u0438 \u0432\u043d\u0443\u043a\u0438<\/figcaption><\/figure>\n<p>\u041c\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u0441\u0440\u0430\u0437\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>UUIDTable<\/code> \u0432\u043c\u0435\u0441\u0442\u043e <code>IdTable&lt;UUID><\/code>, \u043d\u043e \u0442\u043e\u0433\u0434\u0430 \u043d\u0430\u043c \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0431\u044b \u043e\u0442\u0434\u0430\u0442\u044c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0443 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0435\u0439 \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430, \u0430 \u0443 \u043d\u0430\u0441 \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u044b\u0439 \u043a\u043b\u044e\u0447 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<h2>\u041c\u0430\u043f\u0438\u043d\u0433 \u043c\u0435\u0436\u0434\u0443 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044f\u043c\u0438.<\/h2>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0435\u0449\u0430\u043d\u043d\u0430\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b Table API \u0432\u043d\u0435 \u043f\u0440\u0435\u0434\u0435\u043b\u043e\u0432 \u0421\u043f\u0440\u0438\u043d\u0433\u0430.<\/p>\n<p>\u041e\u0442\u043b\u0438\u0447\u0438\u0435 Exposed \u043e\u0442 \u0434\u0440\u0443\u0433\u0438\u0445 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u043d\u0443\u044e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u043d\u0435\u043b\u044c\u0437\u044f \u043d\u0430\u0431\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0438\u0445 \u0432 \u0431\u0430\u0437\u0443 \u0438\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0442\u0442\u0443\u0434\u0430 \u0434\u0430\u043d\u043d\u044b\u0435. \u041e\u043d\u0430 \u043b\u0438\u0448\u044c \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 API \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0442\u043e\u0439 \u0438\u043b\u0438 \u0438\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439. \u0414\u043b\u044f \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0431\u0438\u0437\u043d\u0435\u0441-\u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0438 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 \u0431\u0438\u0437\u043d\u0435\u0441-\u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0434\u0432\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b: <code>ResultRow<\/code>  (\u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0431\u0430\u0437\u044b) \u0438 <code>Statement<\/code> (\u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0431\u0430\u0437\u0443).<\/p>\n<h3>\u041c\u0430\u043f\u0438\u043d\u0433 \u0438\u0437 \u0431\u0438\u0437\u043d\u0435\u0441-\u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438.<\/h3>\n<p>\u0414\u043b\u044f \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0431\u0430\u0437\u0443 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 <code>Statement<\/code>. \u0427\u0435\u0440\u0435\u0437 \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0439 \u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435, <code>InsertStatement<\/code> \u0438 <code>UpdateStatement<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u0445 <code>insert<\/code> \u0438 <code>update<\/code>.<\/p>\n<p>\u041c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0434\u0432\u0430 \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 &#8212; \u0447\u0435\u0440\u0435\u0437 \u043c\u0430\u043f\u0435\u0440 (\u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 <code>ContactMapper<\/code>) \u0438 \u0431\u043e\u043b\u0435\u0435 \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u044b\u0439, \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0432 <code>insert<\/code> \u0438 <code>update<\/code>-\u0437\u0430\u043f\u0440\u043e\u0441\u0430\u0445 (\u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 <code>UserRepository<\/code>).<\/p>\n<p>\u0412 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>insert<\/code> \u0438 <code>update<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 <code>Statement<\/code> \u043a\u0430\u043a \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440. \u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043d\u0430\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 <code>Statement<\/code> \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0438\u0437 \u0431\u0438\u0437\u043d\u0435\u0441-\u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u0412 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043c\u0430\u043f\u0435\u0440\u044b \u0440\u0430\u0437\u043b\u043e\u0436\u0435\u043d\u044b \u043f\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c \u0444\u0430\u0439\u043b\u0430\u043c, \u0440\u0430\u0432\u043d\u043e \u043a\u0430\u043a \u0438 \u0432\u0441\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u043d\u043e \u0434\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438 \u0431\u0443\u0434\u0435\u0442 \u0443\u0434\u043e\u0431\u043d\u044b\u043c \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u043c\u0430\u043f\u0435\u0440\u044b \u0432 \u043e\u0434\u043d\u043e\u043c \u043a\u043e\u0434\u043e\u0432\u043e\u043c \u0431\u043b\u043e\u043a\u0435, \u0431\u043b\u0430\u0433\u043e \u043e\u043d\u0438 \u0443 \u043d\u0430\u0441 \u0433\u043e\u043c\u0435\u043e\u043f\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432.<\/p>\n<pre><code class=\"kotlin\">fun Contact.toInsertStatement(statement: InsertStatement&lt;Number>): InsertStatement&lt;Number> = statement.also {     it[ContactTable.type] = this.type.name     it[ContactTable.value] = this.value     it[ContactTable.userId] = this.userId }  fun Contact.toUpdateStatement(statement: UpdateStatement): UpdateStatement = statement.also {     it[ContactTable.type] = this.type.name     it[ContactTable.value] = this.value     it[ContactTable.userId] = this.userId }<\/code><\/pre>\n<p><code>Statement<\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 <code>Map&lt;Column&lt;*>, Any?><\/code>, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u043d\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0438\u0437 \u0431\u0438\u0437\u043d\u0435\u0441-\u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438. \u0412\u0441\u0451 \u043f\u0440\u043e\u0441\u0442\u043e.<\/p>\n<h3>\u041c\u0430\u043f\u0438\u043d\u0433 \u0432 \u0431\u0438\u0437\u043d\u0435\u0441-\u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c.<\/h3>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 Exposed \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>List&lt;ResultRow><\/code> \u043a\u0430\u043a \u043c\u0430\u0441\u0441\u0438\u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043a\u043e\u043b\u043e\u043d\u043e\u043a \u0441\u0442\u0440\u043e\u043a\u0438. \u0417\u0430\u0434\u0430\u0447\u0430 \u043c\u0430\u043f\u0435\u0440\u0430 &#8212; \u043d\u0430\u043c\u0430\u043f\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043a\u043e\u043b\u043e\u043d\u043e\u043a, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0432 <code>ResultRow<\/code>, \u043d\u0430 \u0431\u0438\u0437\u043d\u0435\u0441-\u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c.<\/p>\n<pre><code class=\"kotlin\">fun ResultRow.toUser(): User = User(     id = this[UserEntity.id].value,     name = this[UserEntity.name],     contacts = this[UserEntity.id].value.let {         ContactEntity.select { ContactEntity.userId eq it }.map { it.toContact() }     } )  fun ResultRow.toContact(): Contact = Contact(     id = this[ContactEntity.id].value,     type = ContactType.valueOf(this[ContactEntity.type]),     value = this[ContactEntity.value],     userId = this[ContactEntity.userId].value )<\/code><\/pre>\n<p>\u041c\u044b \u0431\u0435\u0440\u0451\u043c <code>ResultRow<\/code>, \u0434\u043e\u0441\u0442\u0430\u0451\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0442\u0438\u043f\u0443 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0438 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0443\u0436\u043d\u043e\u043c\u0443 \u043f\u043e\u043b\u044e.<\/p>\n<p>\u0418 \u0432\u0441\u0451.<\/p>\n<p>\u0427\u0442\u043e \u0436\u0435 \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u044f <code>User.contacts<\/code>, \u0437\u0434\u0435\u0441\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0439\u0442\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u043f\u0443\u0442\u044f\u043c\u0438. \u041c\u043e\u0436\u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u0434\u0436\u043e\u0438\u043d \u0442\u0430\u0431\u043b\u0438\u0446, \u0430 \u043c\u043e\u0436\u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u043f\u043e\u0434\u0437\u0430\u043f\u0440\u043e\u0441. \u042f \u043e\u043f\u0438\u0441\u0430\u043b \u0441\u043f\u043e\u0441\u043e\u0431 \u0441 \u043f\u043e\u0434\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c \u043a\u0430\u043a \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0439. \u0412 \u043f\u0440\u043e\u0435\u043a\u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0412\u044b \u0441\u043a\u0430\u0447\u0430\u0435\u0442\u0435 \u0432 \u043a\u043e\u043d\u0446\u0435 \u043f\u043e\u0441\u0442\u0430, \u0435\u0441\u0442\u044c \u0442\u0430\u043a\u0436\u0435 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0447\u0435\u0440\u0435\u0437 \u0434\u0436\u043e\u0438\u043d \u0442\u0430\u0431\u043b\u0438\u0446.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u043c\u044b \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043b\u0438 \u043f\u0440\u043e\u0435\u043a\u0442 \u043a \u0441\u0430\u043c\u043e\u0439 \u0441\u0443\u0442\u0438 \u043f\u043e\u0441\u0442\u0430 &#8212; \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<h2>\u0417\u0430\u043f\u0440\u043e\u0441\u044b \u0432 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445.<\/h2>\n<p>\u041f\u0435\u0440\u0432\u043e\u0435 \u0438 \u0431\u0435\u0441\u043f\u0440\u0435\u043a\u043e\u0441\u043b\u043e\u0432\u043d\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 Exposed: \u0432\u0441\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u044f\u0432\u043d\u043e \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u0434 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0435\u0439. \u0422\u0443\u0442 \u0434\u0432\u0430 \u043f\u0443\u0442\u0438: \u0432\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438-\u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f <code>transaction<\/code>, \u0432\u043e\u0442 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"kotlin\">override fun get(id: UUID): User? = transaction {}<\/code><\/pre>\n<p>\u0438\u043b\u0438 \u0447\u0435\u0440\u0435\u0437 \u0441\u043f\u0440\u0438\u043d\u0433\u043e\u0432\u0443\u044e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e:<\/p>\n<pre><code class=\"kotlin\">@Transactional override fun delete(id: UUID) {}<\/code><\/pre>\n<p>\u0412 \u043f\u0440\u043e\u0435\u043a\u0442\u0435-\u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u043e\u0431\u0430 \u043f\u043e\u0434\u0445\u043e\u0434\u0430, \u043d\u043e \u044f \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u044e \u043f\u0435\u0440\u0432\u044b\u0439.<\/p>\n<h3>SELECT<\/h3>\n<p>\u041e\u0442\u043a\u0440\u044b\u0432 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e, \u043c\u044b \u043f\u0438\u0448\u0435\u043c \u0441\u0430\u043c \u0437\u0430\u043f\u0440\u043e\u0441. \u0421\u0435\u043c\u0430\u043d\u0442\u0438\u043a\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442 SQL. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"kotlin\">override fun get(id: UUID): User? = transaction {     UserEntity.select { UserEntity.id eq id }.firstOrNull()?.toUser() }<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0440\u043e\u0441 \u0432\u044b\u0448\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u0443<\/p>\n<pre><code class=\"sql\">select * from users where id = ?<\/code><\/pre>\n<p>\u0441 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435\u043c \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0438 \u043c\u0430\u043f\u0438\u043d\u0433\u043e\u043c \u0432 User.<\/p>\n<p>\u0414\u0430, \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442, Exposed \u043d\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u043e\u0447\u0435\u043a \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432 \u043e\u0442\u0432\u0435\u0442\u0435 &#8212; \u043e\u0434\u043d\u0443 \u0438\u043b\u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e (\u043a\u0430\u043a \u044d\u0442\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, JOOQ \u0441 \u0435\u0433\u043e <code>fetch()<\/code>, <code>fetchOne()<\/code> \u0438 <code>fetchOptional()<\/code>). \u0420\u0430\u0432\u043d\u043e \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u044b\u0439 SQL-\u0437\u0430\u043f\u0440\u043e\u0441 \u0432\u0435\u0440\u043d\u0451\u0442 \u043d\u0430\u043c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0432 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 select-\u0437\u0430\u043f\u0440\u043e\u0441, \u0442\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u0438 Exposed. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u043a\u043e\u0441\u0442\u044b\u043b\u0451\u043a \u0432 \u0432\u0438\u0434\u0435 <code>first()<\/code> \u0438\u043b\u0438 <code>firstOrNull()<\/code>. \u0418\u043b\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 <code>limit(1)<\/code>, \u043a\u0430\u043a \u0434\u0435\u043b\u0430\u0435\u0442 \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c \u0442\u043e\u0442 \u0436\u0435 JOOQ.<\/p>\n<p>\u0417\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0431\u0443\u0434\u0435\u0442, \u0432 \u0446\u0435\u043b\u043e\u043c, \u043f\u0440\u043e\u0449\u0435:<\/p>\n<pre><code class=\"kotlin\">override fun getAll(limit: Int): List&lt;User> = transaction {     UserEntity.selectAll()         .limit(limit)         .map { it.toUser() } }<\/code><\/pre>\n<p>\u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u044f \u0443\u043a\u0430\u0437\u0430\u043b <code>limit<\/code>, \u043d\u043e \u044d\u0442\u043e\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u0435\u043d. \u0414\u0440\u0443\u0433\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"kotlin\">override fun getAll(userId: UUID): List&lt;Contact> = transaction {     ContactEntity.select { ContactEntity.userId eq userId }         .map { it.toContact() } }<\/code><\/pre>\n<h3>DELETE<\/h3>\n<pre><code class=\"kotlin\">    override fun delete(id: UUID) {         transaction {             ContactEntity.deleteWhere { ContactEntity.id eq id }         }     }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u043f\u0438\u0441\u0435\u0439, \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u044b\u0445 \u043f\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u044e.<\/p>\n<h3>INSERT<\/h3>\n<pre><code class=\"kotlin\">override fun insert(contact: Contact): Contact = transaction {     ContactEntity.insert { contact.toInsertStatement(it) }         .resultedValues?.first()?.toContact()         ?: throw NoSuchElementException(\"Error saving user: ${objectMapperKt.writeValueAsString(contact)}\") }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0443\u0436\u0435 \u0431\u044b\u043b\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u043c\u0430\u043f\u0435\u0440\u043e\u0432, \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>insert()<\/code>  \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u0432\u044b\u0441\u0448\u0435\u0433\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c<code>InsertStatement<\/code>.<\/p>\n<pre><code class=\"kotlin\">fun &lt;T : Table> T.insert(body: T.(InsertStatement&lt;Number>) -> Unit): InsertStatement&lt;Number><\/code><\/pre>\n<p>\u0412\u0441\u0451, \u0447\u0442\u043e \u043d\u0430\u043c \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c &#8212; \u044d\u0442\u043e \u0437\u0430\u043c\u0430\u043f\u0438\u0442\u044c \u0431\u0438\u0437\u043d\u0435\u0441-\u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u0432 <code>InsertStatement<\/code>, \u0447\u0442\u043e \u043c\u044b \u0438 \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u0440\u0430\u043d\u0435\u0435 \u0432 \u043c\u0430\u043f\u0435\u0440\u0435. <code>InsertStatement<\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0442\u0430\u043a\u0436\u0435 \u0434\u0432\u0430 \u043f\u043e\u043b\u044f: <code>insertedCount<\/code> \u0438 <code>resultedValues<\/code>, \u043f\u0435\u0440\u0432\u043e\u0435 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0432 \u0431\u0430\u0437\u0443 \u0437\u0430\u043f\u0438\u0441\u0435\u0439, \u0430 \u0432\u0442\u043e\u0440\u043e\u0435 &#8212; \u0441\u0430\u043c\u0438 \u0437\u0430\u043f\u0438\u0441\u0438. \u0412 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>insertedCount<\/code>, \u0430 \u0432\u043e\u0442 <code>resultedValues<\/code> \u043d\u0430\u043c \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f. \u0421\u043e\u0445\u0440\u0430\u043d\u0451\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442\u0441\u044f \u0432 \u0443\u0436\u0435 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 <code>List&lt;ResultRow><\/code>, \u0447\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e &#8212; \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u043f\u0435\u0440 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 \u0431\u0438\u0437\u043d\u0435\u0441-\u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0440\u0430\u043d\u0435\u0435.<\/p>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>insert<\/code> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u044f\u043c\u0431\u0434\u043e\u0439, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043e\u0434\u0430 \u0438 \u043f\u0440\u043e\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u044f <code>InsertStatement<\/code> \u043f\u0440\u044f\u043c\u043e \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 (\u0447\u0442\u043e \u044f \u0438 \u043e\u0431\u0435\u0449\u0430\u043b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u043c\u0430\u043f\u0435\u0440\u043e\u0432 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 <code>UserRepository<\/code>):<\/p>\n<pre><code class=\"kotlin\">override fun insert(user: User): User = transaction {     UserTable.insert {         it[name] = user.name     }         .resultedValues?.first()?.toUser()         ?: throw NoSuchElementException(             \"Error saving user: ${objectMapperKt.writeValueAsString(user)}. Statement result is null.\"         ) }<\/code><\/pre>\n<p>\u0414\u0430, \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0435\u0440\u0451\u043c \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>insert()<\/code> \u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0435\u0433\u043e \u043f\u043e\u043b\u044f. \u0412\u0441\u0451 \u043f\u0440\u043e\u0441\u0442\u043e.<\/p>\n<h2>UPDATE<\/h2>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f update() \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>insert()<\/code> \u0442\u0435\u043c, \u0447\u0442\u043e \u0432 \u043d\u0435\u0439 &#8212; \u0442\u0440\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0432\u043c\u0435\u0441\u0442\u043e \u043e\u0434\u043d\u043e\u0433\u043e.<\/p>\n<pre><code class=\"kotlin\">fun &lt;T : Table> T.update(where: (SqlExpressionBuilder.() -> Op&lt;Boolean>)? = null, limit: Int? = null, body: T.(UpdateStatement) -> Unit): Int<\/code><\/pre>\n<p>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>limit<\/code> \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u043c, \u043d\u0430\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b \u0434\u0432\u0430 \u0434\u0440\u0443\u0433\u0438\u0445, \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0442\u0430\u043a\u0436\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439. \u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043c\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0443\u0441\u043b\u043e\u0432\u0438\u044f, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0431\u0443\u0434\u0443\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u043d\u044b \u0437\u0430\u043f\u0438\u0441\u0438 \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f, \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u0439 &#8212; \u0441\u0430\u043c\u0443 \u0441\u0443\u0442\u044c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f. \u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u044d\u0442\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"kotlin\">override fun update(contact: Contact) {     transaction {         ContactTable.update({ ContactTable.id eq contact.id!! }) { contact.toUpdateStatement(it) }     } }<\/code><\/pre>\n<p>\u042d\u0442\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043c\u0430\u043f\u0435\u0440 \u0432 <code>Statement<\/code>. \u0415\u0441\u043b\u0438 \u043c\u0430\u043f\u0435\u0440\u0430 \u043d\u0435\u0442, \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0438\u0442\u044c \u043c\u0430\u043f\u0438\u043d\u0433 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u043a\u0430\u043a \u043c\u044b \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u043b\u0438 \u0441 <code>insert()<\/code>.<\/p>\n<pre><code class=\"kotlin\">override fun update(user: User): User = transaction {     UserTable.update({ UserTable.id eq user.id }) {         it[name] = user.name     }     UserTable.select { UserTable.id eq user.id }         .firstOrNull()?.toUser()         ?: throw NoSuchElementException(             \"Error updating user: ${objectMapperKt.writeValueAsString(user)}. Statement result is null.\"         ) }<\/code><\/pre>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0412\u043e\u0442, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0438 \u0432\u0441\u0451.<\/p>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0441\u0430\u043c\u044b\u0435 \u0440\u0430\u0437\u043d\u044b\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438, \u0434\u0430 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0434\u043b\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u044c\u0448\u0435. \u0420\u0430\u0437\u043e\u0431\u0440\u0430\u0432\u0448\u0438\u0441\u044c \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e, \u0412\u044b \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u0435 <code>batchInsert()<\/code>, <code>deleteIgnoreWhere()<\/code>, <code>andWhere()<\/code> \u0438 \u043c\u043d\u043e\u0433\u0438\u0435 \u0434\u0440\u0443\u0433\u0438\u0435 &#8212; \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u043f\u043e\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e.<\/p>\n<p>\u0415\u0441\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f &#8212; \u043f\u0438\u0448\u0438\u0442\u0435, \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043f\u043e\u043c\u043e\u0447\u044c.<\/p>\n<p>\u041e\u0431\u0435\u0449\u0430\u043d\u043d\u044b\u0439 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0442\u0443\u0442: <a href=\"https:\/\/github.com\/promoscow\/exposed-example\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/promoscow\/exposed-example<\/a><\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <\/p>\n<div class=\"tm-article-poll\">\n<div class=\"tm-notice tm-article-poll__notice tm-notice_positive\"><!----> <\/p>\n<div class=\"tm-notice__inner\"><!----> <\/p>\n<div class=\"tm-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\/post\/654163\/&#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<div class=\"tm-article-poll__header\">\u0412\u044b \u0443\u0436\u0435 \u043f\u043e\u0449\u0443\u043f\u0430\u043b\u0438 JetBrains Exposed?<\/div>\n<div class=\"tm-article-poll__answers\">\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\">\u0414\u0430, \u0438 \u043c\u043d\u0435 \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u043e\u0441\u044c.<\/span> <span class=\"tm-article-poll__answer-votes\">             1           <\/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\">             20%           <\/span> <span class=\"tm-article-poll__answer-label\">\u0414\u0430, \u0438 \u043c\u043d\u0435 \u043d\u0435 \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u043e\u0441\u044c.<\/span> <span class=\"tm-article-poll__answer-votes\">             1           <\/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 tm-article-poll__answer-percent_winning\">             60%           <\/span> <span class=\"tm-article-poll__answer-label\">\u041d\u0435\u0442, \u0438 \u043d\u0435 \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u044e.<\/span> <span class=\"tm-article-poll__answer-votes\">             3           <\/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:60%;\"><\/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\">             0%           <\/span> <span class=\"tm-article-poll__answer-label\">\u041d\u0435\u0442, \u043d\u043e \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u044e.<\/span> <span class=\"tm-article-poll__answer-votes\">             0           <\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress\" style=\"width:0%;\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__stats\">        \u041f\u0440\u043e\u0433\u043e\u043b\u043e\u0441\u043e\u0432\u0430\u043b\u0438 5 \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 2 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.      <\/div>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/654163\/\"> https:\/\/habr.com\/ru\/post\/654163\/<\/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<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041f\u0440\u0438 \u0432\u0441\u0451\u043c \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u0438\u0438 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u043e\u0439, \u0441\u0442\u043e\u044f\u0449\u0438\u0445 \u0438 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u044e\u0449\u0438\u0445\u0441\u044f \u043d\u0435 \u0442\u0430\u043a \u0443\u0436 \u0438 \u043c\u043d\u043e\u0433\u043e. \u0418 \u0435\u0441\u043b\u0438 \u043f\u0440\u043e Hibernate \u0437\u043d\u0430\u044e\u0442 \u0432\u0441\u0435, \u0430 \u043f\u0440\u043e JOOQ \u0437\u043d\u0430\u044e\u0442 \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u0438\u0435, \u0442\u043e \u0441\u043b\u0430\u0431\u0430\u044f \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u044c Exposed \u0441\u043a\u043e\u0440\u0435\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u0441 \u0435\u0433\u043e \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439 \u043d\u0430 Kotlin. \u0415\u0441\u043b\u0438 \u0412\u044b \u0442\u043e\u043b\u044c\u043a\u043e-\u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u0448\u043b\u0438 \u0432 Kotlin \u0438\u0437 Java, \u0412\u0430\u043c \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u044b\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b, \u0437\u0430\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u0432 Exposed (\u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043b\u044f\u043c\u0431\u0434\u0430\u043c\u0438 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438-\u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f\u043c\u0438, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443) \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0434\u0438\u0447\u044c\u044e, \u043d\u043e \u043f\u0443\u0433\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u0441\u0442\u043e\u0438\u0442: \u0447\u0435\u043c \u0434\u0430\u043b\u044c\u0448\u0435 \u0412\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u043e\u0441\u0432\u0430\u0438\u0432\u0430\u0442\u044c Kotlin, \u0442\u0435\u043c \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u0435\u0435 \u0434\u043b\u044f \u0412\u0430\u0441 \u0431\u0443\u0434\u0443\u0442 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 Exposed.<\/p>\n<p>\u041a\u0430\u043a\u043e\u0435-\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0437\u0430\u0434 \u0437\u0434\u0435\u0441\u044c \u0443\u0436\u0435 \u0431\u044b\u043b\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u0440\u043e Exposed, \u043e\u0442 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 Otus, \u043d\u043e \u0441 \u0442\u0435\u0445 \u043f\u043e\u0440 \u043f\u0440\u043e\u0448\u043b\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0433\u043e\u0434\u0430 \u0438 \u043c\u043d\u043e\u0433\u0438\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u0441\u0432\u0435\u0436\u0438\u0442\u044c &#8212; \u0434\u0430\u0436\u0435 \u043f\u043e\u043a\u0430 \u044f \u043f\u0438\u0441\u0430\u043b \u044d\u0442\u0443 \u0441\u0442\u0430\u0442\u044c\u044e, \u043c\u043d\u043e\u0433\u043e\u0435 \u043f\u043e\u043c\u0435\u043d\u044f\u043b\u043e\u0441\u044c!<\/p>\n<h2>\u0418\u0442\u0430\u043a, \u043f\u043e\u0447\u0435\u043c\u0443 Exposed?<\/h2>\n<p>\u0412\u043e\u043e\u0431\u0449\u0435, \u0442\u0435\u043c\u0430 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0432\u043d\u0435\u0448\u043d\u0438\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430\u043c, \u043a\u043e\u0438\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438 \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0435\u0441\u044c\u043c\u0430 \u0434\u0438\u0441\u043a\u0443\u0441\u0441\u0438\u043e\u043d\u043d\u043e\u0439 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432. \u0423\u0433\u043e\u0434\u0438\u0442\u044c \u0441 \u0432\u044b\u0431\u043e\u0440\u043e\u043c \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u0431\u044b\u0432\u0430\u0435\u0442 \u0442\u044f\u0436\u0435\u043b\u043e \u0434\u0430\u0436\u0435 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b &#8212; \u0447\u0442\u043e \u0443\u0436 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043e \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0435 \u0432 \u0446\u0435\u043b\u043e\u043c. \u0412 \u0438\u0434\u0435\u0430\u043b\u0435, \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435 \u0436\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432 \u0431\u0430\u0437\u0443 \u043d\u0430 \u0441\u0432\u043e\u0435\u0439 \u043b\u044e\u0431\u0438\u043c\u043e\u0439 \u0434\u0436\u0430\u0432\u0435 \u0438\u043b\u0438 \u043a\u043e\u0442\u043b\u0438\u043d\u0435, \u043d\u043e \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 SQL, \u0438 \u0437\u0434\u0435\u0441\u044c \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 &#8212; \u0432 \u043a\u0430\u043a\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0451\u0442 \u0433\u0440\u0430\u043d\u0438\u0446\u0430 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u043e\u0442 Java \/ Kotlin \u0432 SQL \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e? \u041e\u0434\u043d\u0430 \u043a\u0440\u0430\u0439\u043d\u043e\u0441\u0442\u044c &#8212; Hibernate, c \u0435\u0433\u043e \u043f\u043e\u043b\u043d\u043e\u0439 \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439 \u043d\u0430 \u041e\u041e\u041f \u0438 \u0432\u044b\u0442\u0435\u043a\u0430\u044e\u0449\u0438\u043c\u0438 \u043e\u0442\u0441\u044e\u0434\u0430 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f, \u0434\u0440\u0443\u0433\u0430\u044f &#8212; JDBC, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0448\u043b\u0430 \u0432 1997 \u0433\u043e\u0434\u0443, \u043d\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u043b\u0430\u0441\u044c \u0441 2017 \u0433\u043e\u0434\u0430 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0445 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u0430\u0445. \u0412\u0441\u0435 \u043a\u043e\u043c\u043f\u0440\u043e\u043c\u0438\u0441\u0441\u043d\u044b\u0435 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0438 \u0432\u0440\u043e\u0434\u0435 JOOQ, QueryDSL \u0438 Speedment \u043f\u044b\u0442\u0430\u044e\u0442\u0441\u044f \u0441\u0440\u0430\u0441\u0442\u0438\u0442\u044c \u041e\u041e\u041f \u0438 \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0447\u0435\u0440\u0435\u0437 \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0441\u0432\u043e\u0438 API. \u0418, \u043a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u043f\u043e \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044e \u0438 \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u044e Exposed, \u043f\u043e\u043f\u044b\u0442\u043a\u0438 \u044d\u0442\u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044e\u0442\u0441\u044f.<\/p>\n<h2>\u0414\u043e\u0440\u043e\u0436\u043d\u0430\u044f \u043a\u0430\u0440\u0442\u0430 \u043f\u043e\u0441\u0442\u0430.<\/h2>\n<p>\u0418\u0442\u0430\u043a, \u0442\u043e \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043f\u043e\u0441\u0442\u0430?<\/p>\n<ol>\n<li>\n<p>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043c \u043f\u0440\u043e\u0435\u043a\u0442.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043c \u0432\u0441\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e: \u0431\u0438\u0437\u043d\u0435\u0441-\u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, API, \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<li>\n<p>\u041e\u043f\u0438\u0448\u0435\u043c \u043c\u0430\u043f\u0438\u043d\u0433 \u043c\u0435\u0436\u0434\u0443 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u044b.<\/p>\n<\/li>\n<\/ol>\n<p>\u042d\u0442\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0412\u044b \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b\u0438 \u043d\u043e\u0432\u044b\u0439 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u043d\u0430 \u0432\u043a\u0443\u0441. \u0412 \u043a\u043e\u043d\u0446\u0435 \u043f\u043e\u0441\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442, \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e.<\/p>\n<h2>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a.<\/h2>\n<p>\u0415\u0449\u0451 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0433\u043e\u0434 \u043d\u0430\u0437\u0430\u0434, \u043d\u0430\u043c \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0446\u0435\u043b\u044b\u0439 \u0432\u043e\u0440\u043e\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0438 \u043f\u0438\u0441\u0430\u0442\u044c \u0446\u0435\u043b\u0443\u044e \u044d\u0442\u0430\u0436\u0435\u0440\u043a\u0443 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a. \u0417\u0430 \u0433\u043e\u0434 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0430 \u043b\u043e\u0433\u0438\u0447\u043d\u0430\u044f \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u044f \u0434\u043e \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u043e\u0433\u043e \u0441\u0442\u0430\u0440\u0442\u0435\u0440\u0430 \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Exposed \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043e\u0434\u0438\u043d \u0438\u043c\u043f\u043e\u0440\u0442:<\/p>\n<pre><code>implementation(\"org.jetbrains.exposed:exposed-spring-boot-starter:0.38.2\")<\/code><\/pre>\n<p>\u0412\u0441\u0451. Exposed \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0451\u043d \u0438 \u0433\u043e\u0442\u043e\u0432 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b.<\/p>\n<p>\u0414\u0430, \u0440\u0430\u043d\u044c\u0448\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u043b\u0438 \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 -> \u043f\u043e\u0442\u043e\u043c \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043b\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438\u0437 \u043a\u043e\u043d\u0444\u0438\u0433\u043e\u0432 \u0421\u043f\u0440\u0438\u043d\u0433\u0430 -> \u0442\u0435\u043f\u0435\u0440\u044c \u044d\u0442\u043e \u0432\u0441\u0451 \u0432 \u0441\u0442\u0430\u0440\u0442\u0435\u0440\u0435. \u0420\u0430\u043d\u044c\u0448\u0435, \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043f\u0440\u0438\u043d\u0433\u043e\u0432\u0443\u044e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e Transactional, \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 &#8212; \u0442\u0435\u043f\u0435\u0440\u044c \u044d\u0442\u043e \u0432\u0441\u0451 \u0432 \u0441\u0442\u0430\u0440\u0442\u0435\u0440\u0435. \u0412 \u043e\u0431\u0449\u0435\u043c, \u0447\u0443\u0432\u0441\u0442\u0432\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 Jetbrains. \u0414\u0430, \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0430\u0442 \u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 &#171;\u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438&#187;, \u0438 \u0442\u0430\u043a\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043f\u043e\u043a\u0430 \u0432\u0441\u0451-\u0442\u0430\u043a\u0438 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0437\u0430\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e, \u043d\u043e, \u0441\u0443\u0434\u044f \u043f\u043e \u0442\u0435\u043d\u0434\u0435\u043d\u0446\u0438\u0438, \u043d\u0430\u0434\u043e\u0431\u043d\u043e\u0441\u0442\u044c \u0432 \u0441\u043a\u043e\u0440\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u0440\u043e\u043f\u0430\u0434\u0451\u0442 \u0438 \u0432 \u044d\u0442\u043e\u043c.<\/p>\n<p>\u0418\u0434\u0451\u043c \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<h2>\u0413\u043e\u0442\u043e\u0432\u0438\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445.<\/h2>\n<p>\u041b\u044e\u0431\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u0441 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439. \u0421 \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0447\u043d\u0451\u043c \u0438 \u043c\u044b. \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f c \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u0430\u044f:<\/p>\n<figure class=\"full-width\"><figcaption>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0434\u0430\u043d\u043d\u044bx<\/figcaption><\/figure>\n<h4>\u0411\u0438\u0437\u043d\u0435\u0441-\u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c.<\/h4>\n<pre><code class=\"kotlin\">data class User(       val id: UUID? = null,       val name: String? = null,       val contacts: List&lt;Contact>? = null )  data class Contact(     val id: UUID? = null,     val type: ContactType,     val value: String? = null,     val userId: UUID )  enum class ContactType {     PHONE, EMAIL }<\/code><\/pre>\n<h4>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 (\u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f).<\/h4>\n<pre><code class=\"sql\">create table users ( id   uuid default gen_random_uuid() primary key,     name varchar(512) );  create table contacts (     id      uuid default gen_random_uuid() primary key,     type    varchar(128) not null,     value   varchar(256),     user_id uuid         constraint contacts_user_id_fkey references users );<\/code><\/pre>\n<p>\u042d\u0442\u0438 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u043a\u043e\u043d\u0446\u0430\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0418\u0445 \u0431\u0443\u0434\u0435\u0442 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0442\u044c Table API (\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u043d\u0430\u044f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c), \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 Kotlin.<\/p>\n<h4>Table API (\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u043d\u044b\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438).<\/h4>\n<pre><code class=\"kotlin\">object UserTable : IdTable&lt;UUID>(\"users\") {   override val id = uuid(\"id\").entityId()       val name = varchar(\"name\", 512).nullable() }  object ContactTable : IdTable&lt;UUID>(\"contacts\") {     override val id = ContactEntity.uuid(\"id\").entityId()     val type = varchar(\"type\", 128)     val value = varchar(\"value\", 256).nullable()     val userId = reference(\"user_id\", UserEntity) }<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u0435.<\/p>\n<p>\u041d\u0435\u0441\u043e\u043c\u043d\u0435\u043d\u043d\u044b\u0439 \u043f\u043b\u044e\u0441 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u043d\u044b\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u0438\u0437 \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d\u043e\u0432 \u0432\u043d\u0435 \u043e\u0440\u0431\u0438\u0442\u044b Spring \u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u0432 \u043b\u044e\u0431\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043d\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u044f\u0441\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438 Spring &#8212; \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043d\u0430\u0448\u0438 \u043c\u0430\u043f\u0435\u0440\u044b \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438 Spring, \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u043e\u0432\u0441\u044e \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c API Exposed.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435, \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 Table API Exposed \u043d\u0435 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043a\u0430\u043a \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 JOOQ &#8212; \u0438 \u044d\u0442\u043e \u0442\u043e\u0436\u0435 \u043d\u0435\u0441\u043e\u043c\u043d\u0435\u043d\u043d\u044b\u0439 \u043f\u043b\u044e\u0441. \u0412\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0435 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u043d\u0443\u044e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\u0435 \u0441 \u043d\u0435\u0439. \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0412\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0412\u0430\u0448\u0443 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u043e\u0442 <code>org.jetbrains.exposed.sql.Table<\/code>.<\/p>\n<p>\u0423 <code>Table<\/code> \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a <code>IdTable<\/code>, \u0430 \u0443 \u043d\u0435\u0433\u043e &#8212; \u0435\u0449\u0451 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u0434\u0430\u044e\u0442 \u0442\u0438\u043f <code>id<\/code> \u0432 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u043c \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439:<\/p>\n<figure class=\"full-width\"><figcaption>Table, \u0435\u0433\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u0438 \u0438 \u0432\u043d\u0443\u043a\u0438<\/figcaption><\/figure>\n<p>\u041c\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u0441\u0440\u0430\u0437\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>UUIDTable<\/code> \u0432\u043c\u0435\u0441\u0442\u043e <code>IdTable&lt;UUID><\/code>, \u043d\u043e \u0442\u043e\u0433\u0434\u0430 \u043d\u0430\u043c \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0431\u044b \u043e\u0442\u0434\u0430\u0442\u044c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0443 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0435\u0439 \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430, \u0430 \u0443 \u043d\u0430\u0441 \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u044b\u0439 \u043a\u043b\u044e\u0447 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<h2>\u041c\u0430\u043f\u0438\u043d\u0433 \u043c\u0435\u0436\u0434\u0443 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044f\u043c\u0438.<\/h2>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0435\u0449\u0430\u043d\u043d\u0430\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b Table API \u0432\u043d\u0435 \u043f\u0440\u0435\u0434\u0435\u043b\u043e\u0432 \u0421\u043f\u0440\u0438\u043d\u0433\u0430.<\/p>\n<p>\u041e\u0442\u043b\u0438\u0447\u0438\u0435 Exposed \u043e\u0442 \u0434\u0440\u0443\u0433\u0438\u0445 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u043d\u0443\u044e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u043d\u0435\u043b\u044c\u0437\u044f \u043d\u0430\u0431\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0438\u0445 \u0432 \u0431\u0430\u0437\u0443 \u0438\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0442\u0442\u0443\u0434\u0430 \u0434\u0430\u043d\u043d\u044b\u0435. \u041e\u043d\u0430 \u043b\u0438\u0448\u044c \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 API \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0442\u043e\u0439 \u0438\u043b\u0438 \u0438\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439. \u0414\u043b\u044f \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0431\u0438\u0437\u043d\u0435\u0441-\u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0438 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 \u0431\u0438\u0437\u043d\u0435\u0441-\u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0434\u0432\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b: <code>ResultRow<\/code>  (\u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0431\u0430\u0437\u044b) \u0438 <code>Statement<\/code> (\u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0431\u0430\u0437\u0443).<\/p>\n<h3>\u041c\u0430\u043f\u0438\u043d\u0433 \u0438\u0437 \u0431\u0438\u0437\u043d\u0435\u0441-\u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438.<\/h3>\n<p>\u0414\u043b\u044f \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0431\u0430\u0437\u0443 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 <code>Statement<\/code>. \u0427\u0435\u0440\u0435\u0437 \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0439 \u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435, <code>InsertStatement<\/code> \u0438 <code>UpdateStatement<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u0445 <code>insert<\/code> \u0438 <code>update<\/code>.<\/p>\n<p>\u041c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0434\u0432\u0430 \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 &#8212; \u0447\u0435\u0440\u0435\u0437 \u043c\u0430\u043f\u0435\u0440 (\u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 <code>ContactMapper<\/code>) \u0438 \u0431\u043e\u043b\u0435\u0435 \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u044b\u0439, \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0432 <code>insert<\/code> \u0438 <code>update<\/code>-\u0437\u0430\u043f\u0440\u043e\u0441\u0430\u0445 (\u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 <code>UserRepository<\/code>).<\/p>\n<p>\u0412 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>insert<\/code> \u0438 <code>update<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 <code>Statement<\/code> \u043a\u0430\u043a \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440. \u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043d\u0430\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 <code>Statement<\/code> \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0438\u0437 \u0431\u0438\u0437\u043d\u0435\u0441-\u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u0412 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043c\u0430\u043f\u0435\u0440\u044b \u0440\u0430\u0437\u043b\u043e\u0436\u0435\u043d\u044b \u043f\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c \u0444\u0430\u0439\u043b\u0430\u043c, \u0440\u0430\u0432\u043d\u043e \u043a\u0430\u043a \u0438 \u0432\u0441\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u043d\u043e \u0434\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438 \u0431\u0443\u0434\u0435\u0442 \u0443\u0434\u043e\u0431\u043d\u044b\u043c \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u043c\u0430\u043f\u0435\u0440\u044b \u0432 \u043e\u0434\u043d\u043e\u043c \u043a\u043e\u0434\u043e\u0432\u043e\u043c \u0431\u043b\u043e\u043a\u0435, \u0431\u043b\u0430\u0433\u043e \u043e\u043d\u0438 \u0443 \u043d\u0430\u0441 \u0433\u043e\u043c\u0435\u043e\u043f\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432.<\/p>\n<pre><code class=\"kotlin\">fun Contact.toInsertStatement(statement: InsertStatement&lt;Number>): InsertStatement&lt;Number> = statement.also {     it[ContactTable.type] = this.type.name     it[ContactTable.value] = this.value     it[ContactTable.userId] = this.userId }  fun Contact.toUpdateStatement(statement: UpdateStatement): UpdateStatement = statement.also {     it[ContactTable.type] = this.type.name     it[ContactTable.value] = this.value     it[ContactTable.userId] = this.userId }<\/code><\/pre>\n<p><code>Statement<\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 <code>Map&lt;Column&lt;*>, Any?><\/code>, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u043d\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0438\u0437 \u0431\u0438\u0437\u043d\u0435\u0441-\u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438. \u0412\u0441\u0451 \u043f\u0440\u043e\u0441\u0442\u043e.<\/p>\n<h3>\u041c\u0430\u043f\u0438\u043d\u0433 \u0432 \u0431\u0438\u0437\u043d\u0435\u0441-\u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c.<\/h3>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 Exposed \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>List&lt;ResultRow><\/code> \u043a\u0430\u043a \u043c\u0430\u0441\u0441\u0438\u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043a\u043e\u043b\u043e\u043d\u043e\u043a \u0441\u0442\u0440\u043e\u043a\u0438. \u0417\u0430\u0434\u0430\u0447\u0430 \u043c\u0430\u043f\u0435\u0440\u0430 &#8212; \u043d\u0430\u043c\u0430\u043f\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043a\u043e\u043b\u043e\u043d\u043e\u043a, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0432 <code>ResultRow<\/code>, \u043d\u0430 \u0431\u0438\u0437\u043d\u0435\u0441-\u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c.<\/p>\n<pre><code class=\"kotlin\">fun ResultRow.toUser(): User = User(     id = this[UserEntity.id].value,     name = this[UserEntity.name],     contacts = this[UserEntity.id].value.let {         ContactEntity.select { ContactEntity.userId eq it }.map { it.toContact() }     } )  fun ResultRow.toContact(): Contact = Contact(     id = this[ContactEntity.id].value,     type = ContactType.valueOf(this[ContactEntity.type]),     value = this[ContactEntity.value],     userId = this[ContactEntity.userId].value )<\/code><\/pre>\n<p>\u041c\u044b \u0431\u0435\u0440\u0451\u043c <code>ResultRow<\/code>, \u0434\u043e\u0441\u0442\u0430\u0451\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0442\u0438\u043f\u0443 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0438 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0443\u0436\u043d\u043e\u043c\u0443 \u043f\u043e\u043b\u044e.<\/p>\n<p>\u0418 \u0432\u0441\u0451.<\/p>\n<p>\u0427\u0442\u043e \u0436\u0435 \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u044f <code>User.contacts<\/code>, \u0437\u0434\u0435\u0441\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0439\u0442\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u043f\u0443\u0442\u044f\u043c\u0438. \u041c\u043e\u0436\u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u0434\u0436\u043e\u0438\u043d \u0442\u0430\u0431\u043b\u0438\u0446, \u0430 \u043c\u043e\u0436\u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u043f\u043e\u0434\u0437\u0430\u043f\u0440\u043e\u0441. \u042f \u043e\u043f\u0438\u0441\u0430\u043b \u0441\u043f\u043e\u0441\u043e\u0431 \u0441 \u043f\u043e\u0434\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c \u043a\u0430\u043a \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0439. \u0412 \u043f\u0440\u043e\u0435\u043a\u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0412\u044b \u0441\u043a\u0430\u0447\u0430\u0435\u0442\u0435 \u0432 \u043a\u043e\u043d\u0446\u0435 \u043f\u043e\u0441\u0442\u0430, \u0435\u0441\u0442\u044c \u0442\u0430\u043a\u0436\u0435 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0447\u0435\u0440\u0435\u0437 \u0434\u0436\u043e\u0438\u043d \u0442\u0430\u0431\u043b\u0438\u0446.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u043c\u044b \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043b\u0438 \u043f\u0440\u043e\u0435\u043a\u0442 \u043a \u0441\u0430\u043c\u043e\u0439 \u0441\u0443\u0442\u0438 \u043f\u043e\u0441\u0442\u0430 &#8212; \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<h2>\u0417\u0430\u043f\u0440\u043e\u0441\u044b \u0432 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445.<\/h2>\n<p>\u041f\u0435\u0440\u0432\u043e\u0435 \u0438 \u0431\u0435\u0441\u043f\u0440\u0435\u043a\u043e\u0441\u043b\u043e\u0432\u043d\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 Exposed: \u0432\u0441\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u044f\u0432\u043d\u043e \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u0434 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0435\u0439. \u0422\u0443\u0442 \u0434\u0432\u0430 \u043f\u0443\u0442\u0438: \u0432\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438-\u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f <code>transaction<\/code>, \u0432\u043e\u0442 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"kotlin\">override fun get(id: UUID): User? = transaction {}<\/code><\/pre>\n<p>\u0438\u043b\u0438 \u0447\u0435\u0440\u0435\u0437 \u0441\u043f\u0440\u0438\u043d\u0433\u043e\u0432\u0443\u044e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e:<\/p>\n<pre><code class=\"kotlin\">@Transactional override fun delete(id: UUID) {}<\/code><\/pre>\n<p>\u0412 \u043f\u0440\u043e\u0435\u043a\u0442\u0435-\u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u043e\u0431\u0430 \u043f\u043e\u0434\u0445\u043e\u0434\u0430, \u043d\u043e \u044f \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u044e \u043f\u0435\u0440\u0432\u044b\u0439.<\/p>\n<h3>SELECT<\/h3>\n<p>\u041e\u0442\u043a\u0440\u044b\u0432 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e, \u043c\u044b \u043f\u0438\u0448\u0435\u043c \u0441\u0430\u043c \u0437\u0430\u043f\u0440\u043e\u0441. \u0421\u0435\u043c\u0430\u043d\u0442\u0438\u043a\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442 SQL. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"kotlin\">override fun get(id: UUID): User? = transaction {     UserEntity.select { UserEntity.id eq id }.firstOrNull()?.toUser() }<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0440\u043e\u0441 \u0432\u044b\u0448\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u0443<\/p>\n<pre><code class=\"sql\">select * from users where id = ?<\/code><\/pre>\n<p>\u0441 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435\u043c \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0438 \u043c\u0430\u043f\u0438\u043d\u0433\u043e\u043c \u0432 User.<\/p>\n<p>\u0414\u0430, \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442, Exposed \u043d\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u043e\u0447\u0435\u043a \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432 \u043e\u0442\u0432\u0435\u0442\u0435 &#8212; \u043e\u0434\u043d\u0443 \u0438\u043b\u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e (\u043a\u0430\u043a \u044d\u0442\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, JOOQ \u0441 \u0435\u0433\u043e <code>fetch()<\/code>, <code>fetchOne()<\/code> \u0438 <code>fetchOptional()<\/code>). \u0420\u0430\u0432\u043d\u043e \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u044b\u0439 SQL-\u0437\u0430\u043f\u0440\u043e\u0441 \u0432\u0435\u0440\u043d\u0451\u0442 \u043d\u0430\u043c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0432 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 select-\u0437\u0430\u043f\u0440\u043e\u0441, \u0442\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u0438 Exposed. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u043a\u043e\u0441\u0442\u044b\u043b\u0451\u043a \u0432 \u0432\u0438\u0434\u0435 <code>first()<\/code> \u0438\u043b\u0438 <code>firstOrNull()<\/code>. \u0418\u043b\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 <code>limit(1)<\/code>, \u043a\u0430\u043a \u0434\u0435\u043b\u0430\u0435\u0442 \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c \u0442\u043e\u0442 \u0436\u0435 JOOQ.<\/p>\n<p>\u0417\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0431\u0443\u0434\u0435\u0442, \u0432 \u0446\u0435\u043b\u043e\u043c, \u043f\u0440\u043e\u0449\u0435:<\/p>\n<pre><code class=\"kotlin\">override fun getAll(limit: Int): List&lt;User> = transaction {     UserEntity.selectAll()         .limit(limit)         .map { it.toUser() } }<\/code><\/pre>\n<p>\u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u044f \u0443\u043a\u0430\u0437\u0430\u043b <code>limit<\/code>, \u043d\u043e \u044d\u0442\u043e\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u0435\u043d. \u0414\u0440\u0443\u0433\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"kotlin\">override fun getAll(userId: UUID): List&lt;Contact> = transaction {<\/code><\/pre>\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-332986","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/332986","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=332986"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/332986\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=332986"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=332986"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=332986"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}