Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JSON mapping section to the documentation #2006

Merged
merged 2 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions documentation/src/main/asciidoc/reference/introduction.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,44 @@ If you have very particular requirements, you can check out the Javadoc of
`ReactiveIdentifierGenerator` for information on how to implement your own
custom reactive identifier generator.

=== JSON Mapping

:orm-json-basic-mapping: https://docs.jboss.org/hibernate/orm/6.6/userguide/html_single/Hibernate_User_Guide.html#basic-mapping-json
:orm-json-embeddable-mapping: https://docs.jboss.org/hibernate/orm/6.6/userguide/html_single/Hibernate_User_Guide.html#_jsonxml_aggregate_embeddable_mapping
:string-to-json-converter: https://github.com/hibernate/hibernate-reactive/blob/main/hibernate-reactive-core/src/test/java/org/hibernate/reactive/types/StringToJsonConverter.java

Like in Hibernate ORM, it's possible to map a JSON field using the {orm-json-basic-mapping}[SqlTypes.JSON]
or {orm-json-embeddable-mapping}[an embeddable].

IMPORTANT: Supports for JSON is limited to PostgreSQL and MySQL.
Only PostgreSQL supports mapping a JSON using an embeddable

Hibernate Reactive will recognize fields of type `io.vertx.core.json.JsonObject`
as JSON columns:

[source,java]
----
@Entity
class Example {

JsonObject jsonField;
}
----

Finally, the {string-to-json-converter}[org.hibernate.reactive.StringToJsonConverter] converter is available
for mapping a string to a JSON column:

[source,java]
----
@Entity
class Example {

@Convert(converter = StringToJsonConverter.class)
String json;

}
----

=== Custom types

Hibernate custom types based on the `UserType` interface are targeted toward
Expand Down
1 change: 1 addition & 0 deletions release/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ def updateDocumentationTask = tasks.register( 'updateDocumentation' ) {
}

def stageDocChangesTask = tasks.register( 'stageDocChanges', Exec ) {
dependsOn updateDocumentationTask
workingDir project.layout.buildDirectory.dir( "docs-website" )
commandLine 'git', 'add', '-A', '.'
}
Expand Down
Loading