Funsaized
Funsaized

Reputation: 2140

Mapping MySQL JSON column to hibernate value type

What is the best practice for working with JSON column within Java code? Specifically I am interested in being able to save & query JSON columns in a MySQL DB using hibernate..

@Entity
public class MyEntity {

    private String myField; // this field is a json column

    public MyEntity() {
    }
}

Upvotes: 9

Views: 13416

Answers (1)

Alex Chernyshev
Alex Chernyshev

Reputation: 1745

There is a good library to deal with JSON types in Hibernate. It's called Hibernate Types, and you can scroll down to the MySQL section to get the right example.

And some samples of usage MySQL's JSON API inside query:

How to search JSON data in MySQL?

Upvotes: 3

Related Questions