Coder Social home page Coder Social logo

quarkiverse / quarkus-hibernate-types Goto Github PK

View Code? Open in Web Editor NEW
31.0 6.0 8.0 171 KB

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

License: Apache License 2.0

Java 100.00%
quarkus-extension hibernate hibernate-types

quarkus-hibernate-types's Introduction

Quarkus Hibernate Types

Build License Central

Warning

Quarkus 3.0 integrated Hibernate 6.2, so this extension is no longer needed for JSON type support.

We provide an updated version of this extension anyway, so it is more convenient to upgrade quarkus. It currently looks like that we will not implement any new features in this extension anymore, because hibernate 6.2 should bring you all of the features out of the box.

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/hypersistence-utils#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!

quarkus-hibernate-types's People

Contributors

actions-user avatar allcontributors[bot] avatar andrejpetras avatar brunobastosg avatar dependabot[bot] avatar gastaldi avatar gsmet avatar holly-cummins avatar maxandersen avatar wglanzer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

quarkus-hibernate-types's Issues

@Type(type =JsonTypes.JSON_BIN) error

    @Column(columnDefinition = "jsonb")
    @Comment("元信息")
    @Type(type =JsonTypes.JSON_BIN)
    public Map<String,String> metadata;
Caused by: org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [jsonb]
	at io.quarkus.hibernate.orm.runtime.service.FlatClassLoaderService.classForName(FlatClassLoaderService.java:38)
	at org.hibernate.boot.internal.ClassLoaderAccessImpl.classForName(ClassLoaderAccessImpl.java:67)
	at org.hibernate.cfg.annotations.SimpleValueBinder.fillSimpleValue(SimpleValueBinder.java:536)
	at org.hibernate.cfg.SetSimpleValueTypeSecondPass.doSecondPass(SetSimpleValueTypeSecondPass.java:25)
	at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1653)
	at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1621)
	at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:295)
	at io.quarkus.hibernate.orm.runtime.boot.FastBootMetadataBuilder.build(FastBootMetadataBuilder.java:382)
	at io.quarkus.hibernate.orm.runtime.PersistenceUnitsHolder.createMetadata(PersistenceUnitsHolder.java:101)
	at io.quarkus.hibernate.orm.runtime.PersistenceUnitsHolder.constructMetadataAdvance(PersistenceUnitsHolder.java:73)
	at io.quarkus.hibernate.orm.runtime.PersistenceUnitsHolder.initializeJpa(PersistenceUnitsHolder.java:40)
	at io.quarkus.hibernate.orm.runtime.HibernateOrmRecorder$1.created(HibernateOrmRecorder.java:76)
	at io.quarkus.arc.runtime.ArcRecorder.initBeanContainer(ArcRecorder.java:73)
	at io.quarkus.deployment.steps.ArcProcessor$generateResources1337887788.deploy_0(Unknown Source)
	at io.quarkus.deployment.steps.ArcProcessor$generateResources1337887788.deploy(Unknown Source)
	... 18 more
Caused by: java.lang.ClassNotFoundException: jsonb
	at io.quarkus.launcher.RuntimeLaunchClassLoader.findClass(RuntimeLaunchClassLoader.java:25)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
	at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:505)
	at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:455)
	at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:505)
	at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:455)
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(Class.java:467)
	at io.quarkus.hibernate.orm.runtime.service.FlatClassLoaderService.classForName(FlatClassLoaderService.java:36)
	... 32 more

Add support for "hibernate-reactive"

I noticed in dependencies for this extension that hibernate-orm is referenced. Does this extension support hibernate-reactive?

I am currently using it in a hibernate-reactive environment and everything appears to be working, however I also have a dependency for hibernate-orm and agroal that are not coming from my other dependencies. I believe the hibernate-orm extension is being added from quarkus-hibernate-types.

FYI: When used in a reactive project, quarkus-hibernate-types adds agroal-pool and hibernate-orm to dependencies.

Add a note about this usage with hibernate-reactive

As explained by @Sanne in this thread: https://quarkusio.zulipchat.com/#narrow/stream/187030-users/topic/quarkus-hibernate-types

the hibernate-types project isn't meant to be used by Hibernate Reactive. 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.

It looks like the hibernate-types extension is not intended to be used in reactive scenarios. It would be worth adding a note to the README.md highlighting this.

Looking for new maintainers for quarkus-hibernate-types extension.

Hi,

currently, I do not have much time and I do have more open topics (also in quarkiverse) in open source communities. I do have a feeling I am not supporting the quarkus-hibernate-types extension how I should.

I'm looking for new maintainers to support this extension, implement new features and join the quarkiverse community.

BR
Andrej

PS: the implementation must go on

Given Json object value : '' cannot be clone.

Hello, this is not an issue with the library, but I am unsure of where to find a solution for my problem.

I am using this library for the JSON type capabilities to persist a java object to a postgres database as jsonb.

I am running in to this error when trying to persist:

> java.lang.IllegalArgumentException: The given Json object value: Example{randomuuid='3848a1e8-0694-43f0-a315-9f3c8a09f7c8'} cannot be clone.

Here is some relevant pseudo-code:

@Entity
@TypeDef(name = JsonTypes.JSON_BIN, typeClass = JsonBinaryType.class)
public class Test {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    
    @Column(columnDefinition = JsonTypes.JSON_BIN)
    @Type(type = JsonTypes.JSON_BIN)
    private Example example;
}

Test & Example are created in a helper class and then example is set with a setter method:

Test test = new Test();
Example example = sourceExample;
test.setExample(example);

I am trying to understand the error and what I can do to mitigate it, thanks.

Support for class io.vertx.core.json.JsonObject

Since Quarkus uses Vertx under the hood, class io.vertx.core.json.JsonObject is already available to represent a JSON object.

It would be great to have support for this type. Sometimes, I don't want to create a POJO just to represent a JSON column. I could use a Map, but a JsonObject is simpler, and have a fluent API.

Array types are missing

Hi,

I've migrated a Spring project to Quarkus and by doing so I had an issue when using Vlad Mihalcea's hibernate-types within a Quarkus native-image. I checked back in the Quarkus Zulipchat if there is a way to fix it and I got recommended this project.

The issue I'm now facing when using this project is that all the array types are missing.

Would be great if this can be added to this project.

Quarkus uses hibernate 6.4 but this lib still depends on hypersistence-utils-hibernate-62

Hi Team!

I tried to update my project from quarkus 3.2.9 to 3.7.4 but faced this issue https://hibernate.atlassian.net/browse/HHH-17678

There was an upgrade of Hibernate from 6.2 to 6.4 but this quarkus-hibernate-types lib still depends on the hypersistence-utils-hibernate-62 lib for the hibernate 6.2. Could you upgrade the dependency to hypersistence-utils-hibernate-63 to support the latest quarkus versions?

https://github.com/vladmihalcea/hypersistence-utils?tab=readme-ov-file#hibernate-64-and-63

Where to find the release?

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

Resolution failed. Which repository to use?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.