使用JPA Hibernate从sequence vs manualy insert设置id

时间:2015-02-04 15:31:24

标签: java hibernate jpa generator sequence

我有使用序列生成id的实体

@Id
@SequenceGenerator(name = "ENTITY_SEQ", sequenceName = "ENTITY_SEQ", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ENTITY_SEQ")
@Column(name = "ID", unique = true, nullable = false)
public Long getId() {
    return id;
}

它运作正常。但是当我进行折磨测试并设置id manualy时,序列重写值并设置它自己的值。是否有可能将设置值的优先级更改为ID?

0 个答案:

没有答案