Skip to content

Commit 0d92060

Browse files
committed
[#1606] Add JSON mapping to the documentation
1 parent adeabc1 commit 0d92060

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

documentation/src/main/asciidoc/reference/introduction.adoc

+38
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,44 @@ If you have very particular requirements, you can check out the Javadoc of
576576
`ReactiveIdentifierGenerator` for information on how to implement your own
577577
custom reactive identifier generator.
578578

579+
=== JSON Mapping
580+
581+
:orm-json-basic-mapping: https://docs.jboss.org/hibernate/orm/6.6/userguide/html_single/Hibernate_User_Guide.html#basic-mapping-json
582+
:orm-json-embeddable-mapping: https://docs.jboss.org/hibernate/orm/6.6/userguide/html_single/Hibernate_User_Guide.html#_jsonxml_aggregate_embeddable_mapping
583+
:string-to-json-converter: https://github.com/hibernate/hibernate-reactive/blob/main/hibernate-reactive-core/src/test/java/org/hibernate/reactive/types/StringToJsonConverter.java
584+
585+
Like in Hibernate ORM, it's possible to map a JSON field using the {orm-json-basic-mapping}[SqlTypes.JSON]
586+
or {orm-json-embeddable-mapping}[an embeddable].
587+
588+
IMPORTANT: Supports for JSON is limited to PostgreSQL and MySQL.
589+
Only PostgreSQL supports mapping a JSON using an embeddable
590+
591+
Hibernate Reactive will recognize fields of type `io.vertx.core.json.JsonObject`
592+
as JSON columns:
593+
594+
[source,java]
595+
----
596+
@Entity
597+
class Example {
598+
599+
JsonObject jsonField;
600+
}
601+
----
602+
603+
Finally, the {string-to-json-converter}[org.hibernate.reactive.StringToJsonConverter] converter is available
604+
for mapping a string to a JSON column:
605+
606+
[source,java]
607+
----
608+
@Entity
609+
class Example {
610+
611+
@Convert(converter = StringToJsonConverter.class)
612+
String json;
613+
614+
}
615+
----
616+
579617
=== Custom types
580618

581619
Hibernate custom types based on the `UserType` interface are targeted toward

0 commit comments

Comments
 (0)