Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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() {
    }
}
like image 774
Funsaized Avatar asked Mar 23 '18 13:03

Funsaized


1 Answers

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?

like image 181
Alex Chernyshev Avatar answered Sep 21 '22 09:09

Alex Chernyshev