{"id":378280,"date":"2024-06-07T15:00:46","date_gmt":"2024-06-07T15:00:46","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=378280"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=378280","title":{"rendered":"<span>\u041a\u0430\u0442\u0430\u0441\u0442\u0440\u043e\u0444\u0430 \u0441 Hibernate 6.5 \u043f\u0440\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438 \u043d\u0430 Spring Boot 3.3.0<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041e\u0431\u043d\u043e\u0432\u0438\u0432\u0448\u0438\u0441\u044c \u0434\u043e Spring Boot 3.3.0 (\u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u0434\u043e Hibernate 6.5), \u043c\u044b \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0438\u0441\u044c \u0441\u043e 100% \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u043d\u0430 \u0411\u0414 \u0438\u0437-\u0437\u0430 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 SQL \u043a\u043e\u0434\u0435, \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e Hibernate \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f JPQL \u0432 SQL.<\/p>\n<figure class=\"bordered full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/8e3\/510\/ac2\/8e3510ac276dd356baa8432b304de2f3.png\" alt=\"Image\" title=\"100% \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u0435 CPU\" width=\"802\" height=\"379\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8e3\/510\/ac2\/8e3510ac276dd356baa8432b304de2f3.png\"\/><\/p>\n<div><figcaption>100% \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u0435 CPU<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 JPQL-\u0437\u0430\u043f\u0440\u043e\u0441 \u0438 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u044f \u0432 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 SQL \u0434\u043b\u044f Hibernate 6.4 \u0438 Hibernate 6.5 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 \u043f\u0443\u0441\u0442\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430.<\/p>\n<pre><code class=\"java\">interface ArticleRepository extends CrudRepository&lt;Article, UUID> {     @Query(\"from Article where publisherId in :ids\")   List&lt;Article> findByPublisherId(List&lt;UUID> ids); } var articles = articleRepository.findByPublisherId(List.of());<\/code><\/pre>\n<p>Hibernate 6.4.X:<\/p>\n<pre><code class=\"sql\">select a1_0.id, a1_0.publisher_id, a1_0.title from article a1_0 where 1=0<\/code><\/pre>\n<p>Hibernate 6.5.X:<\/p>\n<pre><code class=\"sql\">select a1_0.id, a1_0.publisher_id, a1_0.title from article a1_0 where (1 = case when a1_0.publisher_id is not null then 0 end)<\/code><\/pre>\n<p>\u041c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u043d\u0435\u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f, \u043e\u0434\u043d\u0430\u043a\u043e \u0432 PostgreSQL \u043f\u0435\u0440\u0432\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u043e, \u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u043f\u043e\u043b\u043d\u043e\u043c\u0443 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u044b (full table scan).<\/p>\n<p>\u0421\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 derived-query \u0432\u043c\u0435\u0441\u0442\u043e @Query \u0441 JPQL \u0437\u0430\u043f\u0440\u043e\u0441 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f:<\/p>\n<pre><code class=\"java\">interface ArticleRepository extends CrudRepository&lt;Article, UUID> { List&lt;Article> findByPublisherId(List&lt;UUID> ids); } var articles = articleRepository.findByPublisherId(List.of());<\/code><\/pre>\n<pre><code class=\"sql\">select a1_0.id, a1_0.publisher_id, a1_0.title from article a1_0 where a1_0.publisher_id in (?)<\/code><\/pre>\n<p><strong>\u041a\u043e\u043c\u0430\u043d\u0434\u0430 Hibernate \u0443\u0436\u0435 \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u044d\u0442\u043e\u0442 \u0431\u0430\u0433: <\/strong><a href=\"https:\/\/github.com\/hibernate\/hibernate-orm\/pull\/8528\"><strong>https:\/\/github.com\/hibernate\/hibernate-orm\/pull\/8528<\/strong><\/a><\/p>\n<p><em>\u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0434\u043e\u0436\u0434\u0430\u0442\u044c\u0441\u044f \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u0444\u0438\u043a\u0441\u0430 \u0432 \u043c\u043e\u0434\u0443\u043b\u044c Spring Data JPA.<\/em><\/p>\n<hr\/>\n<p>\u041f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0439\u0442\u0435\u0441\u044c \u043a \u0440\u0443\u0441\u0441\u043a\u043e\u044f\u0437\u044b\u0447\u043d\u043e\u043c\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u043d\u0430 Spring Boot \u0432 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c &#8212;\u00a0<a href=\"https:\/\/t.me\/spring_aio\">Spring \u0410\u0439\u041e<\/a>, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u0442\u044c \u0432 \u043a\u0443\u0440\u0441\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u043d\u043e\u0432\u043e\u0441\u0442\u0435\u0439 \u0438\u0437 \u043c\u0438\u0440\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043d\u0430 Spring Boot \u0438 \u0432\u0441\u0435\u0433\u043e, \u0447\u0442\u043e \u0441 \u043d\u0438\u043c \u0441\u0432\u044f\u0437\u0430\u043d\u043e.<\/p>\n<p>\u0416\u0434\u0435\u043c \u0432\u0441\u0435\u0445,\u00a0<a href=\"https:\/\/t.me\/spring_aio\"><u>\u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0439\u0442\u0435\u0441\u044c<\/u><\/a>!<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/820175\/\"> https:\/\/habr.com\/ru\/articles\/820175\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041e\u0431\u043d\u043e\u0432\u0438\u0432\u0448\u0438\u0441\u044c \u0434\u043e Spring Boot 3.3.0 (\u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u0434\u043e Hibernate 6.5), \u043c\u044b \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0438\u0441\u044c \u0441\u043e 100% \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u043d\u0430 \u0411\u0414 \u0438\u0437-\u0437\u0430 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 SQL \u043a\u043e\u0434\u0435, \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e Hibernate \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f JPQL \u0432 SQL.<\/p>\n<figure class=\"bordered full-width\">\n<div><figcaption>100% \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u0435 CPU<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 JPQL-\u0437\u0430\u043f\u0440\u043e\u0441 \u0438 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u044f \u0432 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 SQL \u0434\u043b\u044f Hibernate 6.4 \u0438 Hibernate 6.5 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 \u043f\u0443\u0441\u0442\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430.<\/p>\n<pre><code class=\"java\">interface ArticleRepository extends CrudRepository&lt;Article, UUID> {     @Query(\"from Article where publisherId in :ids\")   List&lt;Article> findByPublisherId(List&lt;UUID> ids); } var articles = articleRepository.findByPublisherId(List.of());<\/code><\/pre>\n<p>Hibernate 6.4.X:<\/p>\n<pre><code class=\"sql\">select a1_0.id, a1_0.publisher_id, a1_0.title from article a1_0 where 1=0<\/code><\/pre>\n<p>Hibernate 6.5.X:<\/p>\n<pre><code class=\"sql\">select a1_0.id, a1_0.publisher_id, a1_0.title from article a1_0 where (1 = case when a1_0.publisher_id is not null then 0 end)<\/code><\/pre>\n<p>\u041c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u043d\u0435\u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f, \u043e\u0434\u043d\u0430\u043a\u043e \u0432 PostgreSQL \u043f\u0435\u0440\u0432\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u043e, \u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u043f\u043e\u043b\u043d\u043e\u043c\u0443 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u044b (full table scan).<\/p>\n<p>\u0421\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 derived-query \u0432\u043c\u0435\u0441\u0442\u043e @Query \u0441 JPQL \u0437\u0430\u043f\u0440\u043e\u0441 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f:<\/p>\n<pre><code class=\"java\">interface ArticleRepository extends CrudRepository&lt;Article, UUID> { List&lt;Article> findByPublisherId(List&lt;UUID> ids); } var articles = articleRepository.findByPublisherId(List.of());<\/code><\/pre>\n<pre><code class=\"sql\">select a1_0.id, a1_0.publisher_id, a1_0.title from article a1_0 where a1_0.publisher_id in (?)<\/code><\/pre>\n<p><strong>\u041a\u043e\u043c\u0430\u043d\u0434\u0430 Hibernate \u0443\u0436\u0435 \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u044d\u0442\u043e\u0442 \u0431\u0430\u0433: <\/strong><a href=\"https:\/\/github.com\/hibernate\/hibernate-orm\/pull\/8528\"><strong>https:\/\/github.com\/hibernate\/hibernate-orm\/pull\/8528<\/strong><\/a><\/p>\n<p><em>\u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0434\u043e\u0436\u0434\u0430\u0442\u044c\u0441\u044f \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u0444\u0438\u043a\u0441\u0430 \u0432 \u043c\u043e\u0434\u0443\u043b\u044c Spring Data JPA.<\/em><\/p>\n<hr\/>\n<p>\u041f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0439\u0442\u0435\u0441\u044c \u043a \u0440\u0443\u0441\u0441\u043a\u043e\u044f\u0437\u044b\u0447\u043d\u043e\u043c\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u043d\u0430 Spring Boot \u0432 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c &#8212;\u00a0<a href=\"https:\/\/t.me\/spring_aio\">Spring \u0410\u0439\u041e<\/a>, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u0442\u044c \u0432 \u043a\u0443\u0440\u0441\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u043d\u043e\u0432\u043e\u0441\u0442\u0435\u0439 \u0438\u0437 \u043c\u0438\u0440\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043d\u0430 Spring Boot \u0438 \u0432\u0441\u0435\u0433\u043e, \u0447\u0442\u043e \u0441 \u043d\u0438\u043c \u0441\u0432\u044f\u0437\u0430\u043d\u043e.<\/p>\n<p>\u0416\u0434\u0435\u043c \u0432\u0441\u0435\u0445,\u00a0<a href=\"https:\/\/t.me\/spring_aio\"><u>\u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0439\u0442\u0435\u0441\u044c<\/u><\/a>!<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/820175\/\"> https:\/\/habr.com\/ru\/articles\/820175\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-378280","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/378280","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=378280"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/378280\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=378280"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=378280"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=378280"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}