简体   繁体   English

@SequenceGenerator不起作用

[英]@SequenceGenerator is not working

Today I got very strange behavior. 今天我的行为很奇怪。 I have declared a model with a primary key that uses @SequenceGenerator : 我已经声明了一个使用@SequenceGenerator的主键模型:

@SequenceGenerator(name="EMP_SEQ_GEN", sequenceName="EMP_SEQ")
@Id
@GeneratedValue(generator="EMP_SEQ_GEN_GEN")
@Column(name = "EMP_ID", unique = true, nullable = false, precision = 22, scale = 0)
public Long getEmpId() {
   return this.empId;
}

It works locally but it doesn't work on the server. 它在本地工作,但在服务器上不工作。 I have connected to the same database from both environments. 我已经从两个环境连接到相同的数据库。

我认为您的@GeneratedValue应该看起来像@GeneratedValue(策略= GenerationType.SEQUENCE,生成器=“ EMP_SEQ_GEN”)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM