Reputation: 1691
Because of some limitation, client asked that I can't use incremental "id" primary key, only compound primary key is allowed. And I can't use JPA annotation to have entity callback. Thus how can I know an entity is going to be inserted or updated ? thanks a lot.
Upvotes: 1
Views: 550
Reputation: 33785
Use a version column
@Version
public Integer getVersion() {
return this.version;
}
Whether it is null so it is an insert else it is an update.
regards,
Upvotes: 1