我在应用程序MySQL 5.7中使用,我有JSON列.当我尝试运行时,我的集成测试不起作用,因为H2数据库无法创建表.这是错误:
2016-09-21 16:35:29.729 ERROR 10981 --- [ main] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000389: Unsuccessful: create table payment_transaction (id bigint generated by default as identity, creation_date timestamp not null, payload json, period integer, public_id varchar(255) not null, state varchar(255) not null, subscription_id_zuora varchar(255), type varchar(255) not null, user_id bigint not null, primary key (id))
2016-09-21 16:35:29.730 ERROR 10981 --- [ main] org.hibernate.tool.hbm2ddl.SchemaExport : Unknown data type: "JSON"; SQL statement:
Run Code Online (Sandbox Code Playgroud)
这是实体类.
@Table(name = "payment_transaction")
public class PaymentTransaction extends DomainObject implements Serializable {
@Convert(converter …Run Code Online (Sandbox Code Playgroud) 我的应用程序使用 jhipster 和 mysql 和 liquibase,mysql 版本是 5.7.20,支持 json 列,我使用ObjectMapper映射 json 列和 java 对象,它可以工作,列类型是 json,但是当涉及 liquibase 时( ./mvnw package -Pprod dockerfile:build),会出现“unknown data type 'JSON'”之类的异常,测试会失败,不会生成docker镜像。
我在 20180410012441_added_entity_Ability.xml 中对该 json 列进行了一些更改:
<column name="abilities" type="json">
<constraints nullable="true"/>
</column>
Run Code Online (Sandbox Code Playgroud)
在我的域类中,json相关字段如下:
@Type(type = "json")
@Column(columnDefinition = "json")
private List<Skill> abilities = new ArrayList<>();
Run Code Online (Sandbox Code Playgroud)
我怀疑问题与 xml 列/类型定义有关,liquibase 不支持 json 关键字,我不知道正确的类型应该有什么。
有人可以帮忙吗?非常感激。
=================================================== ======= 北京时间 9:01 PM 更新 我添加了一个changeSet为“
<changeSet id="20180415081741-1" author="jhipster">
<sql dbms="mysql" endDelimiter="\nGO" splitStatements="true"
stripComments="true">ALTER TABLE `ability` ADD `abilities` json DEFAULT NULL</sql>
</changeSet> …Run Code Online (Sandbox Code Playgroud)