【发布时间】:2018-09-10 10:39:05
【问题描述】:
当我使用 PostgreSQL 数据库在 Jpa 中创建表实体时,
tire -
@Entity
@Immutable
public class User_entity_t implements Serializable, Cloneable {
private static final long serialVersionUID = -7049957706738879274L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id", updatable = false, nullable = false)
private Long _judId;
@Column(nullable = false)
private String name;
我得到异常
{syntax error at or near "auto_increment"} Primary Key Id
【问题讨论】:
-
听起来好像您的混淆层不知道 Postgres 如何处理“自动递增”列(
serial或identity) -
1) 您应该避免使用 AUTO 并选择 IDENTITY。 2) auto_increment 听起来像 MySQL 你有正确的方言集吗?
-
@SimonMartinelli 感谢您的回复。但是当我使用 Id GeneratedValue(strategy = GenerationType.IDENTITY) Column(columnDefinition = "serial") private Long id;同样的错误
-
你确定你为 Postgres 设置了正确的语法吗?
标签: postgresql hibernate spring-data-jpa