{"id":338436,"date":"2022-09-16T15:00:22","date_gmt":"2022-09-16T15:00:22","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=338436"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=338436","title":{"rendered":"<span>\u041a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0438\u043f JSONB \u0432 PostgreSQL \u0441 Hibernate<\/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\/w1560\/getpro\/habr\/upload_files\/7da\/203\/b6f\/7da203b6f8dbb8f9878879e558d0e09b.png\" width=\"780\" height=\"439\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7da\/203\/b6f\/7da203b6f8dbb8f9878879e558d0e09b.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041c\u043d\u043e\u0433\u0438\u0435 \u0421\u0423\u0411\u0414, \u043f\u043e\u043c\u0438\u043c\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0430 SQL, \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u043f\u0440\u043e\u043f\u0440\u0438\u0435\u0442\u0430\u0440\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c. \u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <a href=\"https:\/\/www.postgresql.org\/docs\/9.4\/static\/datatype-json.html\" rel=\"noopener noreferrer nofollow\"><u>\u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 JSONB \u0432 PostgreSQL<\/u><\/a>, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c JSON-\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b.<\/p>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0445\u0440\u0430\u043d\u0438\u0442\u044c JSON-\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \u043c\u043e\u0436\u043d\u043e \u0438 \u0432 \u0432\u0438\u0434\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430 \u2014 \u044d\u0442\u043e \u0432\u0445\u043e\u0434\u0438\u0442 \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442 SQL \u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f Hibernate \u0438 JPA. \u041d\u043e \u0442\u043e\u0433\u0434\u0430 \u0432\u0430\u043c \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 PostgreSQL \u043f\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 JSON, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f JSON \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 <a href=\"https:\/\/www.postgresql.org\/docs\/9.4\/static\/functions-json.html\" rel=\"noopener noreferrer nofollow\"><u>\u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b<\/u><\/a>. \u0425\u043e\u0442\u044f, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0432\u044b \u043e\u0431 \u044d\u0442\u043e\u043c \u0443\u0436\u0435 \u0437\u043d\u0430\u0435\u0442\u0435, \u0440\u0430\u0437 \u0447\u0438\u0442\u0430\u0435\u0442\u0435 \u044d\u0442\u043e\u0442 \u043f\u043e\u0441\u0442.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043b\u043e\u043d\u043a\u0443 \u0442\u0438\u043f\u0430 JSONB \u0441 Hibernate 6, \u0442\u043e \u0443 \u043c\u0435\u043d\u044f \u0434\u043b\u044f \u0432\u0430\u0441 \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0435 \u043d\u043e\u0432\u043e\u0441\u0442\u0438. \u0412 Hibernate 6 \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043c\u0430\u043f\u043f\u0438\u043d\u0433 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u043d\u0430 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 JSON \u2014 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0433\u043e \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, Hibernate 4 \u0438 5 \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442 JSON-\u043c\u0430\u043f\u043f\u0438\u043d\u0433, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438 \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c <code>UserType<\/code>. \u041c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043e\u0431\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430.<\/p>\n<h3>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c<\/h3>\n<p>\u041f\u0435\u0440\u0435\u0434 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 <code>UserType<\/code> \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0431\u044b\u0441\u0442\u0440\u043e \u0432\u0437\u0433\u043b\u044f\u043d\u0435\u043c \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c.<\/p>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0431\u0443\u0434\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432: <code>id<\/code> (\u043f\u0435\u0440\u0432\u0438\u0447\u043d\u044b\u0439 \u043a\u043b\u044e\u0447) \u0438 <code>jsonproperty<\/code> \u0442\u0438\u043f\u0430 JSONB.<\/p>\n<pre><code>CREATE TABLE myentity (   id bigint NOT NULL,   jsonproperty jsonb,   CONSTRAINT myentity_pkey PRIMARY KEY (id) )<\/code><\/pre>\n<p>\u0421\u0443\u0449\u043d\u043e\u0441\u0442\u044c, \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c\u0430\u044f \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c.<\/p>\n<pre><code>@Entity public class MyEntity {        @Id     @GeneratedValue     private Long id;        private MyJson jsonProperty;            ... }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u0437\u0434\u0435\u0441\u044c \u043d\u0435\u0442 \u043d\u0438\u0447\u0435\u0433\u043e JSON-\u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u043e\u0433\u043e, \u043a\u0440\u043e\u043c\u0435 \u043f\u043e\u043b\u044f \u0442\u0438\u043f\u0430 <code>MyJson<\/code>. \u041a\u043b\u0430\u0441\u0441 <code>MyJson<\/code> \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0439 POJO \u0441 \u0434\u0432\u0443\u043c\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438.<\/p>\n<pre><code>public class MyJson implements Serializable {        private String stringProp;            private Long longProp;        public String getStringProp() {         return stringProp;     }        public void setStringProp(String stringProp) {         this.stringProp = stringProp;     }        public Long getLongProp() {         return longProp;     }        public void setLongProp(Long longProp) {         this.longProp = longProp;     } }<\/code><\/pre>\n<p>\u0418\u0442\u0430\u043a, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 <code>MyJson<\/code> \u0432 JSONB? \u041e\u0442\u0432\u0435\u0442 \u043d\u0430 \u044d\u0442\u043e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0432\u0435\u0440\u0441\u0438\u0438 Hibernate.<\/p>\n<p>\u0412 Hibernate 4 \u0438 5 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u043c\u0430\u043f\u043f\u0438\u043d\u0433. \u041d\u0435 \u043f\u0435\u0440\u0435\u0436\u0438\u0432\u0430\u0439\u0442\u0435. \u042d\u0442\u043e \u043d\u0435 \u0442\u0430\u043a \u0443\u0436 \u0441\u043b\u043e\u0436\u043d\u043e, \u043a\u0430\u043a \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <code>UserType<\/code> \u0438 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u043f\u043f\u0438\u043d\u0433.<\/p>\n<p>\u0421 Hibernate 6 \u0432\u0441\u0435 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0449\u0435. \u041e\u043d \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043c\u0430\u043f\u043f\u0438\u043d\u0433 JSON \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441 \u043d\u0435\u0433\u043e \u0438 \u043d\u0430\u0447\u043d\u0435\u043c.<\/p>\n<h3>\u041c\u0430\u043f\u043f\u0438\u043d\u0433 JSONB \u0432 Hibernate 6<\/h3>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0435 JSON, \u043f\u043e\u044f\u0432\u0438\u0432\u0448\u0435\u0439\u0441\u044f \u0432 Hibernate 6, \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0430\u043d\u043d\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0435\u0439 <code>@JdbcTypeCode<\/code> \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0442\u0438\u043f <code>SqlTypes.JSON<\/code>. Hibernate \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 JSON \u0432 <code>classpath<\/code> \u0438 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0435 \u0434\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.<\/p>\n<pre><code>@Entity public class MyEntity {        @Id     @GeneratedValue     private Long id;        @JdbcTypeCode(SqlTypes.JSON)     private MyJson jsonProperty;            ... }<\/code><\/pre>\n<p><code>@JdbcTypeCode<\/code> \u2014 \u044d\u0442\u043e \u043d\u043e\u0432\u0430\u044f \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u044b\u043b\u0430 \u0432\u0432\u0435\u0434\u0435\u043d\u0430 \u0434\u043b\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0430 \u043d\u043e\u0432\u044b\u0445 \u0442\u0438\u043f\u043e\u0432. \u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 Hibernate 6, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043c\u0430\u043f\u043f\u0438\u043d\u0433 Java \u0438 JDBC \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e, \u0430\u043d\u043d\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u0432 \u043f\u043e\u043b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0435\u0439 <code>@JdbcTypeCode<\/code> \u0438\u043b\u0438 <code>@JavaType<\/code>. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u044d\u0442\u0438 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u043e\u0432 Hibernate \u0438\u043b\u0438 \u0441\u0432\u043e\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432 <code>JavaTypeDescriptor<\/code> \u0438\u043b\u0438 <code>JdbcTypeDescriptor<\/code>. \u041e\u0431 \u044d\u0442\u0438\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430\u0445 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435, \u0430 \u0437\u0434\u0435\u0441\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043c\u0430\u043f\u043f\u0438\u043d\u0433 Hibernate.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0430\u043d\u043d\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u043b\u044f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u0438 \u0435\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u0432 \u0441\u0432\u043e\u0435\u043c \u0431\u0438\u0437\u043d\u0435\u0441-\u043a\u043e\u0434\u0435. \u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438.<\/p>\n<h3>\u041c\u0430\u043f\u043f\u0438\u043d\u0433 JSONB \u0432 Hibernate 4 \u0438 5<\/h3>\n<p>\u041a\u0430\u043a \u044f \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b \u0440\u0430\u043d\u0435\u0435, \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f JSONB \u0432 PostgreSQL \u0441 Hibernate 4 \u0438\u043b\u0438 5 \u0432\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u043c\u0430\u043f\u043f\u0438\u043d\u0433. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 Hibernate <code>UserType<\/code> \u0438 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u043c\u0430\u043f\u043f\u0438\u043d\u0433 \u0432 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u043c \u0434\u0438\u0430\u043b\u0435\u043a\u0442\u0435.<\/p>\n<h4>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f UserType<\/h4>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e <code>UserType<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 MyJson \u0441 JSON-\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u043c \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 SQL-\u0442\u0438\u043f \u0434\u043b\u044f \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0430. \u0414\u0430\u043b\u0435\u0435 \u044f \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0432\u0430\u0436\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 <code>MyJsonType<\/code>. \u041f\u043e\u043b\u043d\u044b\u0439 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 \u0432 <a href=\"https:\/\/github.com\/thjanssen\/HibernateJSONBSupport\" rel=\"noopener noreferrer nofollow\"><u>\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 GitHub<\/u><\/a>.<\/p>\n<p>\u0412 <code>UserType<\/code> \u043d\u0430\u0434\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b <code>sqlTypes<\/code> \u0438 <code>returnedClass<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u043e\u0431\u0449\u0430\u044e\u0442 Hibernate SQL-\u0442\u0438\u043f \u0438 Java-\u043a\u043b\u0430\u0441\u0441, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0434\u043b\u044f \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0430. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e <code>Type.JAVA_OBJECT<\/code> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0442\u0438\u043f\u0430 SQL \u0438, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u043a\u043b\u0430\u0441\u0441 <code>MyJson<\/code> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 Java-\u043a\u043b\u0430\u0441\u0441\u0430.<\/p>\n<pre><code>public class MyJsonType implements UserType {        @Override     public int[] sqlTypes() {         return new int[]{Types.JAVA_OBJECT};     }        @Override     public Class&lt;MyJson> returnedClass() {         return MyJson.class;     }            ... }<\/code><\/pre>\n<p>\u0417\u0430\u0442\u0435\u043c \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b <code>nullSafeGet<\/code> \u0438 <code>nullSafeSet<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 Hibernate \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 <code>nullSafeGet<\/code> \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043a\u043b\u0430\u0441\u0441 Java. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u043f\u0430\u0440\u0441\u0438\u043c JSON-\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \u0432 \u043a\u043b\u0430\u0441\u0441 <code>MyJson<\/code>. \u042f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e <code>ObjectMapper<\/code> \u0438\u0437 Jackson, \u043d\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u0430\u0440\u0441\u0435\u0440 JSON.<\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 <code>nullSafeSet<\/code> \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043c\u0430\u043f\u043f\u0438\u043d\u0433 \u043a\u043b\u0430\u0441\u0441\u0430 MyJson \u0432 JSON-\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f Jackson, \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u043e\u0433\u043e \u0436\u0435 <code>ObjectMapper<\/code>, \u0447\u0442\u043e \u0438 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <code>nullSafeGet<\/code>.<\/p>\n<pre><code>@Override public Object nullSafeGet(final ResultSet rs, final String[] names, final SessionImplementor session,                           final Object owner) throws HibernateException, SQLException {     final String cellContent = rs.getString(names[0]);     if (cellContent == null) {         return null;     }     try {         final ObjectMapper mapper = new ObjectMapper();         return mapper.readValue(cellContent.getBytes(\"UTF-8\"), returnedClass());     } catch (final Exception ex) {         throw new RuntimeException(\"Failed to convert String to Invoice: \" + ex.getMessage(), ex);     } }    @Override public void nullSafeSet(final PreparedStatement ps, final Object value, final int idx,                         final SessionImplementor session) throws HibernateException, SQLException {     if (value == null) {         ps.setNull(idx, Types.OTHER);         return;     }     try {         final ObjectMapper mapper = new ObjectMapper();         final StringWriter w = new StringWriter();         mapper.writeValue(w, value);         w.flush();         ps.setObject(idx, w.toString(), Types.OTHER);     } catch (final Exception ex) {         throw new RuntimeException(\"Failed to convert Invoice to String: \" + ex.getMessage(), ex);     } }<\/code><\/pre>\n<p>\u0415\u0449\u0435 \u043e\u0434\u0438\u043d \u0432\u0430\u0436\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c, \u2014 \u044d\u0442\u043e \u043c\u0435\u0442\u043e\u0434 <code>deepCopy<\/code>, \u0441\u043e\u0437\u0434\u0430\u044e\u0449\u0438\u0439 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Object_copying#Deep_copy\" rel=\"noopener noreferrer nofollow\"><u>\u0433\u043b\u0443\u0431\u043e\u043a\u0443\u044e \u043a\u043e\u043f\u0438\u044e<\/u><\/a> \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <code>MyJson<\/code>. \u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u2014 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 <code>MyJson<\/code>.<\/p>\n<pre><code>@Override public Object deepCopy(final Object value) throws HibernateException {     try {         \/\/ use serialization to create a deep copy         ByteArrayOutputStream bos = new ByteArrayOutputStream();         ObjectOutputStream oos = new ObjectOutputStream(bos);         oos.writeObject(value);         oos.flush();         oos.close();         bos.close();                    ByteArrayInputStream bais = new ByteArrayInputStream(bos.toByteArray());         Object obj = new ObjectInputStream(bais).readObject();         bais.close();         return obj;     } catch (ClassNotFoundException | IOException ex) {         throw new HibernateException(ex);     } }<\/code><\/pre>\n<h4>\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f UserType<\/h4>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0448\u0443 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e <code>UserType<\/code> \u0432 \u0444\u0430\u0439\u043b\u0435 <code>package-info.java<\/code> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 <code>@TypeDef<\/code>.<\/p>\n<pre><code>@org.hibernate.annotations.TypeDef(name = \"MyJsonType\", typeClass = MyJsonType.class)    package org.thoughts.on.java.model;<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0442\u0438\u043f <code>MyJsonType<\/code> \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441 \u0438\u043c\u0435\u043d\u0435\u043c &#171;MyJsonType&#187;, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0434\u0430\u043b\u0435\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 <code>@Type<\/code> \u043f\u0440\u0438 \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438.<\/p>\n<pre><code>@Entity public class MyEntity {        @Id     @GeneratedValue(strategy = GenerationType.AUTO)     @Column(name = \"id\", updatable = false, nullable = false)     private Long id;        @Column     @Type(type = \"MyJsonType\")     private MyJson jsonProperty;            ...    }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c Hibernate \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>UserType<\/code> <code>MyJsonType<\/code> \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044f <code>jsonproperty<\/code> \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u041e\u0434\u043d\u0430\u043a\u043e \u043e\u0441\u0442\u0430\u043b\u0441\u044f \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0448\u0430\u0433.<\/p>\n<h4>\u0414\u0438\u0430\u043b\u0435\u043a\u0442 Hibernate<\/h4>\n<p>\u0414\u0438\u0430\u043b\u0435\u043a\u0442 PostgreSQL \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 JSONB, \u0435\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u043c\u0441\u044f \u043e\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u0434\u0438\u0430\u043b\u0435\u043a\u0442\u0430 \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u043c\u0435\u0442\u043e\u0434 <code>registerColumnType<\/code>.<\/p>\n<pre><code>public class MyPostgreSQL94Dialect extends PostgreSQL94Dialect {        public MyPostgreSQL94Dialect() {         this.registerColumnType(Types.JAVA_OBJECT, \"jsonb\");     } }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 <code>MyJson<\/code> \u0432 \u0441\u0442\u043e\u043b\u0431\u0446\u0435 JSONB.<\/p>\n<h3>\u041a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u0441 JSONB \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u043e\u043c<\/h3>\n<p>\u041a\u0430\u043a \u0432\u044b \u043f\u043e\u043d\u044f\u043b\u0438 \u0438\u0437 \u0441\u0442\u0430\u0442\u044c\u0438, \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0430 JSONB \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 Hibernate. \u041d\u043e \u044d\u0442\u043e \u043d\u0435 \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0431\u0438\u0437\u043d\u0435\u0441-\u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u0438\u043b\u0438 \u0435\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c <code>MyEntity<\/code> \u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 <code>MyJson<\/code> \u0442\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u0438 \u043b\u044e\u0431\u0443\u044e \u0434\u0440\u0443\u0433\u0443\u044e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c. \u0418 \u043f\u0440\u0438 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 Hibernate 6 \u044d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u0432\u043e\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e <code>UserType<\/code> \u043d\u0430 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a Hibernate.<\/p>\n<p>\u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0438\u0436\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 <code>EntityManager.find<\/code> \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <code>MyJson<\/code>.<\/p>\n<pre><code>MyEntity e = em.find(MyEntity.class, 10000L); e.getJsonProperty().setStringProp(\"changed\"); e.getJsonProperty().setLongProp(789L);<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0432\u043d\u0443\u0442\u0440\u0438 JSON-\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0435 SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0441 <a href=\"https:\/\/www.postgresql.org\/docs\/9.4\/static\/functions-json.html\" rel=\"noopener noreferrer nofollow\"><u>\u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438 \u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430\u043c\u0438 PostgreSQL \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 JSON<\/u><\/a>.<\/p>\n<pre><code>MyEntity e = (MyEntity) em.createNativeQuery(\"SELECT * FROM myentity e WHERE e.jsonproperty->'longProp' = '456'\", MyEntity.class).getSingleResult();<\/code><\/pre>\n<h3>\u0420\u0435\u0437\u044e\u043c\u0435<\/h3>\n<p>PostgreSQL \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u0440\u043e\u043f\u0440\u0438\u0435\u0442\u0430\u0440\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 JSONB \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f JSON-\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>Hibernate 6 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043c\u0430\u043f\u043f\u0438\u043d\u0433 JSON \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438. \u0412\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e, \u0430\u043d\u043d\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u0432 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0435\u0439 <code>@JdbcTypeCode<\/code> \u0441 \u0442\u0438\u043f\u043e\u043c <code>SqlTypes.JSON<\/code>.<\/p>\n<p>\u0412 Hibernate 4 \u0438 5 \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043c\u0430\u043f\u043f\u0438\u043d\u0433 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e, \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <code>UserType<\/code>, \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0432 \u0435\u0433\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 <code>@TypeDef<\/code> \u0438 \u0441\u043e\u0437\u0434\u0430\u0432 \u0434\u0438\u0430\u043b\u0435\u043a\u0442 Hibernate, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u0442\u0438\u043f \u0441\u0442\u043e\u043b\u0431\u0446\u0430.<\/p>\n<hr\/>\n<blockquote>\n<p>\u0421\u043a\u043e\u0440\u043e \u0441\u043e\u0441\u0442\u043e\u0438\u0442\u0441\u044f \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0435 \u0437\u0430\u043d\u044f\u0442\u0438\u0435 <strong>\u00ab\u0421\u0431\u043e\u0440\u0449\u0438\u043a \u043c\u0443\u0441\u043e\u0440\u0430 \u0432 Java\u00bb<\/strong>, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u0431\u0441\u0443\u0434\u0438\u043c \u0442\u0435\u043c\u044b:<br \/>&#8212; Java Memory Model;<br \/>&#8212; 3 \u0441\u0442\u0430\u0434\u0438\u0438 \u0438 2 \u043f\u043e\u043a\u043e\u043b\u0435\u043d\u0438\u044f \u0441\u0431\u043e\u0440\u043a\u0438 \u043c\u0443\u0441\u043e\u0440\u0430;<br \/>&#8212; \u041a\u0430\u0440\u044c\u0435\u0440\u0430 \u0438 \u0433\u0438\u0431\u0435\u043b\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432.<br \/>\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0439\u0442\u0435\u0441\u044c <a href=\"https:\/\/otus.pw\/BTPc\/\" rel=\"noopener noreferrer nofollow\"><strong>\u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435.<\/strong><\/a><\/p>\n<\/blockquote>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/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\/post\/688714\/\"> https:\/\/habr.com\/ru\/post\/688714\/<\/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>\u041c\u043d\u043e\u0433\u0438\u0435 \u0421\u0423\u0411\u0414, \u043f\u043e\u043c\u0438\u043c\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0430 SQL, \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u043f\u0440\u043e\u043f\u0440\u0438\u0435\u0442\u0430\u0440\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c. \u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <a href=\"https:\/\/www.postgresql.org\/docs\/9.4\/static\/datatype-json.html\" rel=\"noopener noreferrer nofollow\"><u>\u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 JSONB \u0432 PostgreSQL<\/u><\/a>, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c JSON-\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b.<\/p>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0445\u0440\u0430\u043d\u0438\u0442\u044c JSON-\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \u043c\u043e\u0436\u043d\u043e \u0438 \u0432 \u0432\u0438\u0434\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430 \u2014 \u044d\u0442\u043e \u0432\u0445\u043e\u0434\u0438\u0442 \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442 SQL \u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f Hibernate \u0438 JPA. \u041d\u043e \u0442\u043e\u0433\u0434\u0430 \u0432\u0430\u043c \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 PostgreSQL \u043f\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 JSON, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f JSON \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 <a href=\"https:\/\/www.postgresql.org\/docs\/9.4\/static\/functions-json.html\" rel=\"noopener noreferrer nofollow\"><u>\u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b<\/u><\/a>. \u0425\u043e\u0442\u044f, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0432\u044b \u043e\u0431 \u044d\u0442\u043e\u043c \u0443\u0436\u0435 \u0437\u043d\u0430\u0435\u0442\u0435, \u0440\u0430\u0437 \u0447\u0438\u0442\u0430\u0435\u0442\u0435 \u044d\u0442\u043e\u0442 \u043f\u043e\u0441\u0442.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043b\u043e\u043d\u043a\u0443 \u0442\u0438\u043f\u0430 JSONB \u0441 Hibernate 6, \u0442\u043e \u0443 \u043c\u0435\u043d\u044f \u0434\u043b\u044f \u0432\u0430\u0441 \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0435 \u043d\u043e\u0432\u043e\u0441\u0442\u0438. \u0412 Hibernate 6 \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043c\u0430\u043f\u043f\u0438\u043d\u0433 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u043d\u0430 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 JSON \u2014 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0433\u043e \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, Hibernate 4 \u0438 5 \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442 JSON-\u043c\u0430\u043f\u043f\u0438\u043d\u0433, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438 \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c <code>UserType<\/code>. \u041c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043e\u0431\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430.<\/p>\n<h3>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c<\/h3>\n<p>\u041f\u0435\u0440\u0435\u0434 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 <code>UserType<\/code> \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0431\u044b\u0441\u0442\u0440\u043e \u0432\u0437\u0433\u043b\u044f\u043d\u0435\u043c \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c.<\/p>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0431\u0443\u0434\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432: <code>id<\/code> (\u043f\u0435\u0440\u0432\u0438\u0447\u043d\u044b\u0439 \u043a\u043b\u044e\u0447) \u0438 <code>jsonproperty<\/code> \u0442\u0438\u043f\u0430 JSONB.<\/p>\n<pre><code>CREATE TABLE myentity (   id bigint NOT NULL,   jsonproperty jsonb,   CONSTRAINT myentity_pkey PRIMARY KEY (id) )<\/code><\/pre>\n<p>\u0421\u0443\u0449\u043d\u043e\u0441\u0442\u044c, \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c\u0430\u044f \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c.<\/p>\n<pre><code>@Entity public class MyEntity {        @Id     @GeneratedValue     private Long id;        private MyJson jsonProperty;            ... }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u0437\u0434\u0435\u0441\u044c \u043d\u0435\u0442 \u043d\u0438\u0447\u0435\u0433\u043e JSON-\u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u043e\u0433\u043e, \u043a\u0440\u043e\u043c\u0435 \u043f\u043e\u043b\u044f \u0442\u0438\u043f\u0430 <code>MyJson<\/code>. \u041a\u043b\u0430\u0441\u0441 <code>MyJson<\/code> \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0439 POJO \u0441 \u0434\u0432\u0443\u043c\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438.<\/p>\n<pre><code>public class MyJson implements Serializable {        private String stringProp;            private Long longProp;        public String getStringProp() {         return stringProp;     }        public void setStringProp(String stringProp) {         this.stringProp = stringProp;     }        public Long getLongProp() {         return longProp;     }        public void setLongProp(Long longProp) {         this.longProp = longProp;     } }<\/code><\/pre>\n<p>\u0418\u0442\u0430\u043a, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 <code>MyJson<\/code> \u0432 JSONB? \u041e\u0442\u0432\u0435\u0442 \u043d\u0430 \u044d\u0442\u043e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0432\u0435\u0440\u0441\u0438\u0438 Hibernate.<\/p>\n<p>\u0412 Hibernate 4 \u0438 5 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u043c\u0430\u043f\u043f\u0438\u043d\u0433. \u041d\u0435 \u043f\u0435\u0440\u0435\u0436\u0438\u0432\u0430\u0439\u0442\u0435. \u042d\u0442\u043e \u043d\u0435 \u0442\u0430\u043a \u0443\u0436 \u0441\u043b\u043e\u0436\u043d\u043e, \u043a\u0430\u043a \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <code>UserType<\/code> \u0438 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u043f\u043f\u0438\u043d\u0433.<\/p>\n<p>\u0421 Hibernate 6 \u0432\u0441\u0435 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0449\u0435. \u041e\u043d \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043c\u0430\u043f\u043f\u0438\u043d\u0433 JSON \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441 \u043d\u0435\u0433\u043e \u0438 \u043d\u0430\u0447\u043d\u0435\u043c.<\/p>\n<h3>\u041c\u0430\u043f\u043f\u0438\u043d\u0433 JSONB \u0432 Hibernate 6<\/h3>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0435 JSON, \u043f\u043e\u044f\u0432\u0438\u0432\u0448\u0435\u0439\u0441\u044f \u0432 Hibernate 6, \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0430\u043d\u043d\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0435\u0439 <code>@JdbcTypeCode<\/code> \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0442\u0438\u043f <code>SqlTypes.JSON<\/code>. Hibernate \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 JSON \u0432 <code>classpath<\/code> \u0438 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0435 \u0434\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.<\/p>\n<pre><code>@Entity public class MyEntity {        @Id     @GeneratedValue     private Long id;        @JdbcTypeCode(SqlTypes.JSON)     private MyJson jsonProperty;            ... }<\/code><\/pre>\n<p><code>@JdbcTypeCode<\/code> \u2014 \u044d\u0442\u043e \u043d\u043e\u0432\u0430\u044f \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u044b\u043b\u0430 \u0432\u0432\u0435\u0434\u0435\u043d\u0430 \u0434\u043b\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0430 \u043d\u043e\u0432\u044b\u0445 \u0442\u0438\u043f\u043e\u0432. \u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 Hibernate 6, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043c\u0430\u043f\u043f\u0438\u043d\u0433 Java \u0438 JDBC \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e, \u0430\u043d\u043d\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u0432 \u043f\u043e\u043b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0435\u0439 <code>@JdbcTypeCode<\/code> \u0438\u043b\u0438 <code>@JavaType<\/code>. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u044d\u0442\u0438 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u043e\u0432 Hibernate \u0438\u043b\u0438 \u0441\u0432\u043e\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432 <code>JavaTypeDescriptor<\/code> \u0438\u043b\u0438 <code>JdbcTypeDescriptor<\/code>. \u041e\u0431 \u044d\u0442\u0438\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430\u0445 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435, \u0430 \u0437\u0434\u0435\u0441\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043c\u0430\u043f\u043f\u0438\u043d\u0433 Hibernate.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0430\u043d\u043d\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u043b\u044f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u0438 \u0435\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u0432 \u0441\u0432\u043e\u0435\u043c \u0431\u0438\u0437\u043d\u0435\u0441-\u043a\u043e\u0434\u0435. \u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438.<\/p>\n<h3>\u041c\u0430\u043f\u043f\u0438\u043d\u0433 JSONB \u0432 Hibernate 4 \u0438 5<\/h3>\n<p>\u041a\u0430\u043a \u044f \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b \u0440\u0430\u043d\u0435\u0435, \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f JSONB \u0432 PostgreSQL \u0441 Hibernate 4 \u0438\u043b\u0438 5 \u0432\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u043c\u0430\u043f\u043f\u0438\u043d\u0433. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 Hibernate <code>UserType<\/code> \u0438 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u043c\u0430\u043f\u043f\u0438\u043d\u0433 \u0432 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u043c \u0434\u0438\u0430\u043b\u0435\u043a\u0442\u0435.<\/p>\n<h4>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f UserType<\/h4>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e <code>UserType<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 MyJson \u0441 JSON-\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u043c \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 SQL-\u0442\u0438\u043f \u0434\u043b\u044f \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0430. \u0414\u0430\u043b\u0435\u0435 \u044f \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0432\u0430\u0436\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 <code>MyJsonType<\/code>. \u041f\u043e\u043b\u043d\u044b\u0439 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 \u0432 <a href=\"https:\/\/github.com\/thjanssen\/HibernateJSONBSupport\" rel=\"noopener noreferrer nofollow\"><u>\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 GitHub<\/u><\/a>.<\/p>\n<p>\u0412 <code>UserType<\/code> \u043d\u0430\u0434\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b <code>sqlTypes<\/code> \u0438 <code>returnedClass<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u043e\u0431\u0449\u0430\u044e\u0442 Hibernate SQL-\u0442\u0438\u043f \u0438 Java-\u043a\u043b\u0430\u0441\u0441, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0434\u043b\u044f \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0430. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e <code>Type.JAVA_OBJECT<\/code> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0442\u0438\u043f\u0430 SQL \u0438, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u043a\u043b\u0430\u0441\u0441 <code>MyJson<\/code> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 Java-\u043a\u043b\u0430\u0441\u0441\u0430.<\/p>\n<pre><code>public class MyJsonType implements UserType {        @Override     public int[] sqlTypes() {         return new int[]{Types.JAVA_OBJECT};     }        @Override     public Class&lt;MyJson> returnedClass() {         return MyJson.class;     }            ... }<\/code><\/pre>\n<p>\u0417\u0430\u0442\u0435\u043c \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b <code>nullSafeGet<\/code> \u0438 <code>nullSafeSet<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 Hibernate \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 <code>nullSafeGet<\/code> \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043a\u043b\u0430\u0441\u0441 Java. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u043f\u0430\u0440\u0441\u0438\u043c JSON-\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \u0432 \u043a\u043b\u0430\u0441\u0441 <code>MyJson<\/code>. \u042f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e <code>ObjectMapper<\/code> \u0438\u0437 Jackson, \u043d\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u0430\u0440\u0441\u0435\u0440 JSON.<\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 <code>nullSafeSet<\/code> \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043c\u0430\u043f\u043f\u0438\u043d\u0433 \u043a\u043b\u0430\u0441\u0441\u0430 MyJson \u0432 JSON-\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f Jackson, \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u043e\u0433\u043e \u0436\u0435 <code>ObjectMapper<\/code>, \u0447\u0442\u043e \u0438 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <code>nullSafeGet<\/code>.<\/p>\n<pre><code>@Override public Object nullSafeGet(final ResultSet rs, final String[] names, final SessionImplementor session,                           final Object owner) throws HibernateException, SQLException {     final String cellContent = rs.getString(names[0]);     if (cellContent == null) {         return null;     }     try {         final ObjectMapper mapper = new ObjectMapper();         return mapper.readValue(cellContent.getBytes(\"UTF-8\"), returnedClass());     } catch (final Exception ex) {         throw new RuntimeException(\"Failed to convert String to Invoice: \" + ex.getMessage(), ex);     } }    @Override public void nullSafeSet(final PreparedStatement ps, final Object value, final int idx,                         final SessionImplementor session) throws HibernateException, SQLException {     if (value == null) {         ps.setNull(idx, Types.OTHER);         return;     }     try {         final ObjectMapper mapper = new ObjectMapper();         final StringWriter w = new StringWriter();         mapper.writeValue(w, value);         w.flush();         ps.setObject(idx, w.toString(), Types.OTHER);     } catch (final Exception ex) {         throw new RuntimeException(\"Failed to convert Invoice to String: \" + ex.getMessage(), ex);     } }<\/code><\/pre>\n<p>\u0415\u0449\u0435 \u043e\u0434\u0438\u043d \u0432\u0430\u0436\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c, \u2014 \u044d\u0442\u043e \u043c\u0435\u0442\u043e\u0434 <code>deepCopy<\/code>, \u0441\u043e\u0437\u0434\u0430\u044e\u0449\u0438\u0439 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Object_copying#Deep_copy\" rel=\"noopener noreferrer nofollow\"><u>\u0433\u043b\u0443\u0431\u043e\u043a\u0443\u044e \u043a\u043e\u043f\u0438\u044e<\/u><\/a> \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <code>MyJson<\/code>. \u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u2014 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 <code>MyJson<\/code>.<\/p>\n<pre><code>@Override public Object deepCopy(final Object value) throws HibernateException {     try {         \/\/ use serialization to create a deep copy         ByteArrayOutputStream bos = new ByteArrayOutputStream();         ObjectOutputStream oos = new ObjectOutputStream(bos);         oos.writeObject(value);         oos.flush();         oos.close();         bos.close();                    ByteArrayInputStream bais = new ByteArrayInputStream(bos.toByteArray());         Object obj = new ObjectInputStream(bais).readObject();         bais.close();         return obj;     } catch (ClassNotFoundException | IOException ex) {         throw new HibernateException(ex);     } }<\/code><\/pre>\n<h4>\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f UserType<\/h4>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0448\u0443 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e <code>UserType<\/code> \u0432 \u0444\u0430\u0439\u043b\u0435 <code>package-info.java<\/code> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 <code>@TypeDef<\/code>.<\/p>\n<pre><code>@org.hibernate.annotations.TypeDef(name = \"MyJsonType\", typeClass = MyJsonType.class)    package org.thoughts.on.java.model;<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0442\u0438\u043f <code>MyJsonType<\/code> \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441 \u0438\u043c\u0435\u043d\u0435\u043c &#171;MyJsonType&#187;, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0434\u0430\u043b\u0435\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 <code>@Type<\/code> \u043f\u0440\u0438 \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438.<\/p>\n<pre><code>@Entity public class MyEntity {        @Id     @GeneratedValue(strategy = GenerationType.AUTO)     @Column(name = \"id\", updatable = false, nullable = false)     private Long id;        @Column     @Type(type = \"MyJsonType\")     private MyJson jsonProperty;            ...    }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c Hibernate \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>UserType<\/code> <code>MyJsonType<\/code> \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044f <code>jsonproperty<\/code> \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u041e\u0434\u043d\u0430\u043a\u043e \u043e\u0441\u0442\u0430\u043b\u0441\u044f \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0448\u0430\u0433.<\/p>\n<h4>\u0414\u0438\u0430\u043b\u0435\u043a\u0442 Hibernate<\/h4>\n<p>\u0414\u0438\u0430\u043b\u0435\u043a\u0442 PostgreSQL \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 JSONB, \u0435\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u043c\u0441\u044f \u043e\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u0434\u0438\u0430\u043b\u0435\u043a\u0442\u0430 \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u043c\u0435\u0442\u043e\u0434 <code>registerColumnType<\/code>.<\/p>\n<pre><code>public class MyPostgreSQL94Dialect extends PostgreSQL94Dialect {        public MyPostgreSQL94Dialect() {         this.registerColumnType(Types.JAVA_OBJECT, \"jsonb\");     } }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 <code>MyJson<\/code> \u0432 \u0441\u0442\u043e\u043b\u0431\u0446\u0435 JSONB.<\/p>\n<h3>\u041a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u0441 JSONB \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u043e\u043c<\/h3>\n<p>\u041a\u0430\u043a \u0432\u044b \u043f\u043e\u043d\u044f\u043b\u0438 \u0438\u0437 \u0441\u0442\u0430\u0442\u044c\u0438, \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0430 JSONB \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 Hibernate. \u041d\u043e \u044d\u0442\u043e \u043d\u0435 \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0431\u0438\u0437\u043d\u0435\u0441-\u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u0438\u043b\u0438 \u0435\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c <code>MyEntity<\/code> \u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 <code>MyJson<\/code> \u0442\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u0438 \u043b\u044e\u0431\u0443\u044e \u0434\u0440\u0443\u0433\u0443\u044e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c. \u0418 \u043f\u0440\u0438 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 Hibernate 6 \u044d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u0432\u043e\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e <code>UserType<\/code> \u043d\u0430 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a Hibernate.<\/p>\n<p>\u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0438\u0436\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 <code>EntityManager.find<\/code> \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <code>MyJson<\/code>.<\/p>\n<pre><code>MyEntity e = em.find(MyEntity.class, 10000L); e.getJsonProperty().setStringProp(\"changed\"); e.getJsonProperty().setLongProp(789L);<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0432\u043d\u0443\u0442\u0440\u0438 JSON-\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0435 SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0441 <a href=\"https:\/\/www.postgresql.org\/docs\/9.4\/static\/functions-json.html\" rel=\"noopener noreferrer nofollow\"><u>\u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438 \u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430\u043c\u0438 PostgreSQL \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 JSON<\/u><\/a>.<\/p>\n<pre><code>MyEntity e = (MyEntity) em.createNativeQuery(\"SELECT * FROM myentity e WHERE e.jsonproperty->'longProp' = '456'\", MyEntity.class).getSingleResult();<\/code><\/pre>\n<h3>\u0420\u0435\u0437\u044e\u043c\u0435<\/h3>\n<p>PostgreSQL \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u0440\u043e\u043f\u0440\u0438\u0435\u0442\u0430\u0440\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 JSONB \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f JSON-\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>Hibernate 6 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043c\u0430\u043f\u043f\u0438\u043d\u0433 JSON \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438. \u0412\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e, \u0430\u043d\u043d\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u0432 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0435\u0439 <code>@JdbcTypeCode<\/code> \u0441 \u0442\u0438\u043f\u043e\u043c <code>SqlTypes.JSON<\/code>.<\/p>\n<p>\u0412 Hibernate 4 \u0438 5 \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043c\u0430\u043f\u043f\u0438\u043d\u0433 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e, \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <code>UserType<\/code>, \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0432 \u0435\u0433\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 <code>@TypeDef<\/code> \u0438 \u0441\u043e\u0437\u0434\u0430\u0432 \u0434\u0438\u0430\u043b\u0435\u043a\u0442 Hibernate, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u0442\u0438\u043f \u0441\u0442\u043e\u043b\u0431\u0446\u0430.<\/p>\n<hr\/>\n<blockquote>\n<p>\u0421\u043a\u043e\u0440\u043e \u0441\u043e\u0441\u0442\u043e\u0438\u0442\u0441\u044f \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0435 \u0437\u0430\u043d\u044f\u0442\u0438\u0435 <strong>\u00ab\u0421\u0431\u043e\u0440\u0449\u0438\u043a \u043c\u0443\u0441\u043e\u0440\u0430 \u0432 Java\u00bb<\/strong>, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u0431\u0441\u0443\u0434\u0438\u043c \u0442\u0435\u043c\u044b:<br \/>&#8212; Java Memory Model;<br \/>&#8212; 3<\/p>\n<\/blockquote>\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-338436","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/338436","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=338436"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/338436\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=338436"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=338436"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=338436"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}