【发布时间】:2017-02-09 23:04:45
【问题描述】:
我正在使用 Spring Boot JPA,但在 application.properties 中没有配置方言。 在我的输出中,我可以看到 Hibernate 正在生成以下 DDL 命令:
create table user
(
id int8 not null,
password varchar(255),
username varchar(255),
primary key (id)
)
这会导致语法错误,因为表名必须用引号引起来。
那是我的 application.properties:
spring.datasource.url=jdbc:postgresql://localhost:5432/springtest
spring.datasource.username=...
spring.datasource.password=...
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.show-sql=true
【问题讨论】:
-
user是保留字(关键字) 尝试其他名称(或引用它CREATE TABLE "user" ...) -
不要使用需要引用的名称,即使您可以说服混淆层这样做。使用保留关键字作为标识符时会遇到更多问题
-
混淆层确实是正确的术语。例如:您多久会看到语法高亮显示出错?只是不要相信它。不要依赖它。这是等待发生的破坏。国际锰协
-
@wildplasser:ORM 不是“模糊关系模型”的缩写吗? (SCNR)
标签: java spring postgresql hibernate jpa