Skip to content

Lavanya-nallu/fresh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License Maven Central JavaDoc

Introduction

The Hibernate Types repository gives you extra types and general-purpose utilities that are not supported by the Hibernate ORM core.

The main advantage of this project is that it supports a broad range of Hibernate versions, spanning from Hibernate ORM 6 to 5.5, 5.4, 5.3, 5.2, 5.1, 5, 4.3, 4.2, and Hibernate 4.1.

Features

JSON

Generic JSON Type

The JsonType allows you to map JSON column types, no matter if you're using Oracle, SQL Server, PostgreSQL or MySQL.

Hibernate 6

If you're using Hibernate 6, you can map any JSON column to Map, List, POJO, String, or JsonNode entity property:

@Type(JsonType.class)
private Map<String, String> properties = new HashMap<>();
Hibernate 5 and 4

If you're using Hibernate 5 or 4, you can either provide the fully-qualified name of the Hibernate Type:

@Type(type = "com.vladmihalcea.hibernate.type.json.JsonType")

Or, you can add the following mapping to your package-info.java class in the same package where your JPA entities are located:

@TypeDef(
    name = "json", typeClass = JsonType.class
)
package io.hypersistence.optimizer;

import com.vladmihalcea.hibernate.type.json.JsonType;
import org.hibernate.annotations.TypeDef;

And later, you can map the Map, List, POJO, String, or JsonNode entity properties to JSON columns like this:

@Type(type = "json")
private Map<String, String> properties = new HashMap<>();

For more details, check out this article.

Best Practices

When mapping a JSON column type to a POJO, List<POJO> or Map<String, POJO>, you need to make sure that the POJO type overrides the default equals and hashCode methods and implements them according to the JSON object content.

Otherwise, the Hibernate dirty checking mechanism may trigger unexpected UPDATE statements. Check out the #134 issue for more details.

Database-specific JSON types
Oracle

When using Oracle, you have several options:

  • you can use the generic JsonType that can work with the JSON, VARCHAR, or BLOB column types, as long as you hint the column type using the columnDefinition attribute of the JPA @Column annotation.
  • you can use the JsonStringType to map a VARCHAR2 column type storing JSON.
  • you can use the JsonBlobType to map a BLOB column type storing JSON.

For more details, check out this article.

SQL Server

When using SQL Server, you can use the generic JsonType or the JsonStringType to map an NVARCHAR column type storing JSON.

For more details, check out this article.

PostgreSQL

When using PostgreSQL, you can use the generic JsonType or the JsonBinaryType to map both jsonb and json column types.

For more details, check out this article.

MySQL

When using MySQL, you can use the generic JsonType or the JsonStringType to map the json column type.

For more details, check out this article.

JSON mapping examples

ARRAY

PostgreSQL Types (e.g. ENUM, INET, HSTORE, RANGE)

Generic Types

Utilities

Identifier Generators
Naming Strategy
DTO Projection and ResultTransformer

Installation

Depending on the Hibernate version you are using, you need to add the following dependency:

Hibernate 6.0

<dependency>
    <groupId>com.vladmihalcea</groupId>
    <artifactId>hibernate-types-60</artifactId>
    <version>2.16.2</version>
</dependency>

Hibernate 5.6 and 5.5

<dependency>
    <groupId>com.vladmihalcea</groupId>
    <artifactId>hibernate-types-55</artifactId>
    <version>2.16.2</version>
</dependency>

Hibernate 5.4, 5.3 and 5.2

<dependency>
    <groupId>com.vladmihalcea</groupId>
    <artifactId>hibernate-types-52</artifactId>
    <version>2.16.2</version>
</dependency>

Hibernate 5.1 and 5.0

<dependency>
    <groupId>com.vladmihalcea</groupId>
    <artifactId>hibernate-types-5</artifactId>
    <version>2.16.2</version>
</dependency>

Hibernate 4.3

<dependency>
    <groupId>com.vladmihalcea</groupId>
    <artifactId>hibernate-types-43</artifactId>
    <version>2.16.2</version>
</dependency>

Hibernate 4.2 and 4.1

<dependency>
    <groupId>com.vladmihalcea</groupId>
    <artifactId>hibernate-types-4</artifactId>
    <version>2.16.2</version>
</dependency>

Requirements

  • Java version supported by the Hibernate ORM version you are using.
  • SLF4J
  • Jackson Databind

Issue management

If you have an issue, then there are two ways to address it.

Option 1: Providing your own fix

Since this project is open-source, you have the ability to fix any issue you bump into. Therefore, when dealing with a problem, this is what you need to do:

  1. Provide a replicating test case using the existing test cases as a template
  2. Provide a fix proposal
  3. Send a Pull Request with the fix proposal and the test case

Option 2: Paid support

If you don't have the time to provide a fix, then I can fix your issue via consulting. If you're in a hurry, this is going to be your best option.

Are you struggling with application performance issues?

Hypersistence Optimizer

Imagine having a tool that can automatically detect if you are using JPA and Hibernate properly. No more performance issues, no more having to spend countless hours trying to figure out why your application is barely crawling.

Imagine discovering early during the development cycle that you are using suboptimal mappings and entity relationships or that you are missing performance-related settings.

More, with Hypersistence Optimizer, you can detect all such issues during testing and make sure you don't deploy to production a change that will affect data access layer performance.

Hypersistence Optimizer is the tool you've been long waiting for!

Training

If you are interested in on-site training, I can offer you my High-Performance Java Persistence training, which can be adapted to one, two or three days of sessions. For more details, check out my website.

Consulting

If you want me to review your application and provide insight into how you can optimize it to run faster, then check out my consulting page.

High-Performance Java Persistence Video Courses

If you want the fastest way to learn how to speed up a Java database application, then you should definitely enroll in my High-Performance Java Persistence video courses.

High-Performance Java Persistence Book

Or, if you prefer reading books, you are going to love my High-Performance Java Persistence book as well.

High-Performance Java Persistence book High-Performance Java Persistence video course

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages