How to map a map JSON column to Java Object with JPA

前端 未结 6 1036
一整个雨季
一整个雨季 2020-12-02 14:22

We have a big table with a lot of columns. After we moved to MySQL Cluster, the table cannot be created because of:

ERROR 1118 (42000): Row size too l

6条回答
  •  误落风尘
    2020-12-02 14:53

    There is a workaround for those don't want write too much code.

    Frontend -> Encode your JSON Object to string base64 in POST method, decode it to json in GET method

    In POST Method
    data.components = btoa(JSON.stringify(data.components));
    
    In GET
    data.components = JSON.parse(atob(data.components))
    

    Backend -> In your JPA code, change the column to String or BLOB, no need Convert.

    @Column(name = "components", columnDefinition = "json")
    private String components;
    

提交回复
热议问题