Enity primary key is an auto_incrimented ID in JDO

@Persistent(primaryKey = "true", valueStrategy = IdGeneratorStrategy.IDENTITY)
    @Column(name = "ID")
    private Long id;

When I am inserting any record, it's primary key ID is being set implicitly as auto_incremented.

I have a requirement in which I want set this ID (PK) using setter(setId()) explicitly while inserting the record.

Can we do this?

有帮助吗?

解决方案

No. As comments say, you either use IDENTITY strategy (so its set by the datastore), or you set it yourself. You can't have both

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top