/quarkus-hibernate-types

Quarkus Extension based on Hibernate Types (https://github.com/vladmihalcea/hibernate-types)

Primary LanguageJavaApache License 2.0Apache-2.0

Quarkus Hibernate Types

Build License Central

Introduction

This module integrates the hibernate extension "hibernate-types" into the quarkus universe, so you are able to support extra types that are not supported by the Hibernate ORM core.

For detailed information, check out the readme of the underlying repository: https://github.com/vladmihalcea/hibernate-types#readme

Detailed examples (including native image generation) can be found under the "integration-tests/simple" module.

Usage

To use this extension, add the following dependency to your project:

<dependency>
  <groupId>io.quarkiverse.hibernatetypes</groupId>
  <artifactId>quarkus-hibernate-types</artifactId>
</dependency>

Now you are able to define the newly added types in your already created entities, by including the "@TypeDef" annotation on your entity class and the "@Type" annotation on the desired json field.

import io.quarkiverse.hibernate.types.json.JsonBinaryType;
import io.quarkiverse.hibernate.types.json.JsonTypes;

/**
 * Declares a simple entity with a nested serialized object.
 * This object will get inserted into a "jsonb" (postgresql) column.
 */
@Entity
@TypeDef(name = JsonTypes.JSON_BIN, typeClass = JsonBinaryType.class)
public class MyEntity {

    /**
     * Unique identifier / primary key for this entity.
     */
    @Id
    private String id;

    /**
     * Nested parameter, that will get inserted into a json column
     */
    @Type(type = JsonTypes.JSON_BIN)
    @Column(name = "PARAM", columnDefinition = JsonTypes.JSON_BIN)
    private MyJsonParam param;

    /**
     * Parameter POJO
     */
    public static class MyJsonParam {
        private String id;
        private String name;
    }
    
}

Limitations

Hibernate Reactive Support

Using hibernate reactive is currently not (fully) supported, because the "hibernate-types" project isn't meant to be used by Hibernate Reactive (see https://quarkusio.zulipchat.com/#narrow/stream/187030-users/topic/quarkus-hibernate-types ).

The "types" notion needs to map to vendor specific types that some databases expose in their proprietary JDBC driver, but Hibernate Reactive doesn't use those drivers.

Contributors ✨

Thanks goes to these wonderful people (emoji key):

All Contributors

Andrej Petras
Andrej Petras

💻 🚧
Werner Glanzer
Werner Glanzer

💻 🚧
Bruno Guimarães
Bruno Guimarães

💻

This project follows the all-contributors specification. Contributions of any kind welcome!