@@ -0,0 +1,3324 @@
+package com.vladmihalcea.book.hpjp.hibernate.type.json;%0A%0Aimport com.fasterxml.jackson.databind.JsonNode;%0Aimport com.vladmihalcea.book.hpjp.util.AbstractPostgreSQLIntegrationTest;%0Aimport com.vladmihalcea.hibernate.type.json.JsonStringType;%0Aimport com.vladmihalcea.hibernate.type.json.JsonType;%0Aimport jakarta.persistence.*;%0Aimport net.ttddyy.dsproxy.QueryCountHolder;%0Aimport org.hibernate.Session;%0Aimport org.hibernate.annotations.NaturalId;%0Aimport org.hibernate.annotations.Type;%0Aimport org.hibernate.jpa.boot.spi.TypeContributorList;%0Aimport org.hibernate.query.NativeQuery;%0Aimport org.junit.Test;%0A%0Aimport java.util.Collections;%0Aimport java.util.Properties;%0A%0Aimport static org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.TYPE_CONTRIBUTORS;%0Aimport static org.junit.Assert.*;%0A%0A/**%0A * @author Vlad Mihalcea%0A */%0Apublic class PostgreSQLJsonTypeRegistryTest extends AbstractPostgreSQLIntegrationTest %7B%0A%0A    @Override%0A    protected Class%3C?%3E%5B%5D entities() %7B%0A        return new Class%3C?%3E%5B%5D%7B%0A            Book.class%0A        %7D;%0A    %7D%0A%0A    @Override%0A    protected void afterInit() %7B%0A        doInJPA(entityManager -%3E %7B%0A            entityManager.persist(%0A                new Book()%0A                    .setIsbn(%22978-9730228236%22)%0A                    .setProperties(%22%22%22%0A                        %7B%0A                           %22title%22: %22High-Performance Java Persistence%22,%0A                           %22author%22: %22Vlad Mihalcea%22,%0A                           %22publisher%22: %22Amazon%22,%0A                           %22price%22: 44.99%0A                        %7D%0A                        %22%22%22%0A                    )%0A            );%0A        %7D);%0A    %7D%0A%0A    @Override%0A    protected void additionalProperties(Properties properties) %7B%0A        properties.put(TYPE_CONTRIBUTORS,%0A            (TypeContributorList) () -%3E Collections.singletonList(%0A                (typeContributions, serviceRegistry) -%3E %7B%0A                    typeContributions.contributeType(new JsonStringType(JsonNode.class));%0A                %7D%0A            )%0A        );%0A    %7D%0A%0A    @Test%0A    public void test() %7B%0A        doInJPA(entityManager -%3E %7B%0A            JsonNode properties = (JsonNode) entityManager.createNativeQuery(%22%22%22%0A                SELECT%0A                  properties AS properties%0A                FROM book%0A                WHERE%0A                  isbn = :isbn%0A                %22%22%22)%0A            .setParameter(%22isbn%22, %22978-9730228236%22)%0A            .unwrap(NativeQuery.class)%0A            .addScalar(%22properties%22, JsonNode.class)%0A            .getSingleResult();%0A%0A            assertEquals(%22High-Performance Java Persistence%22, properties.get(%22title%22).asText());%0A        %7D);%0A    %7D%0A%0A    @Entity(name = %22Book%22)%0A    @Table(name = %22book%22)%0A    public static class Book %7B%0A%0A        @Id%0A        @GeneratedValue%0A        private Long id;%0A%0A        @NaturalId%0A        private String isbn;%0A%0A        @Type(JsonType.class)%0A        @Column(columnDefinition = %22jsonb%22)%0A        private String properties;%0A%0A        public String getIsbn() %7B%0A            return isbn;%0A        %7D%0A%0A        public Book setIsbn(String isbn) %7B%0A            this.isbn = isbn;%0A            return this;%0A        %7D%0A%0A        public String getProperties() %7B%0A            return properties;%0A        %7D%0A%0A        public Book setProperties(String properties) %7B%0A            this.properties = properties;%0A            return this;%0A        %7D%0A    %7D%0A%7D

Add TypeContributor example