【发布时间】:2020-12-16 21:42:17
【问题描述】:
我需要带有 JSON 列的 mysql 表,因此我使用了 vladmihalcea/hibernate-types 依赖项,我按照官方文档做了示例,但我遇到了异常,我该如何克服这个异常。
执行 DDL 时出错“创建表 book (id bigint not null, isbn varchar(255),属性 jsonb,主键 (id)) engine=InnoDB" 通过 JDBC 语句
您的 SQL 语法有错误;检查手册 对应于您的 MySQL 服务器版本,以便使用正确的语法 靠近第 1 行的“jsonb,主键 (id)) engine=InnoDB”
实体类(我已经提交了getter和setter,以便在这里清楚地显示代码,应该添加getter和setter)
@Entity(name = "Book")
@Table(name = "book")
@TypeDef(
name = "jsonb",
typeClass = JsonBinaryType.class
)
public class Book {
@Id
@GeneratedValue
private Long id;
@NaturalId
private String isbn;
@Type(type = "jsonb")
@Column(columnDefinition = "jsonb")
private String properties;
}
存储库接口
@Repository
public interface BookRepository extends JpaRepository<Book,Long> {
}
【问题讨论】:
标签: java mysql spring-boot hibernate spring-data-jpa