未知的数据类型:“ JSON”

sil*_*uez 2 java hibernate

我们试图在休眠状态下定义一个json列,如下所示:

实体类:

@TypeDef( name="CustomType", CustomJSONType.class)
...
@Type( name = "CustomType")
@Column
private JSONObject myColumn;
...
Run Code Online (Sandbox Code Playgroud)

CustomJSONType类实现UserType

当应用程序运行时,日志显示以下错误跟踪:

2018-02-06 08:46:44.067错误[company-operations-module ,,] 11804 --- [main] org.hibernate.tool.hbm2ddl.SchemaExport:HHH000389:不成功:创建表操作(id int4 not null ,创建时间戳记不为null,类型varchar(50)不为null,request_data json不为空,response_data json,状态varchar(50)不为空,user_id varchar(30),主键(id))2018-02-06 08:46 :44.067错误[操作模块,,] 11804 --- [主] org.hibernate.tool.hbm2ddl.SchemaExport:未知数据类型:“ JSON”未知数据类型:“ JSON”;SQL语句:创建表操作(id int4不为空,创建时间戳记不为空,类型varchar(50)不为空,request_data json ...)[50004-190] 2018-02-06 08:46:44.067 INFO [operations-模块,] 11804-[main] org.hibernate.tool.hbm2ddl。

任何的想法?提前致谢。

Vla*_*lad 5

也可以使用“创建域”选项将H2配置为以JSON作为文本。例如,在连接URL中:

jdbc:h2:~/test;AUTO_SERVER=TRUE;INIT=create domain if not exists json as text
Run Code Online (Sandbox Code Playgroud)