I have a resource that needs to be exposed through a restful service. I want it to have multiple revisions of a resource(every time it is updated). I have id(resource id) and a subid (revision id)
id 1 subid 0
id 1 subid 1
id 1 subid 2
id 2 subid 0
In a post here I tried with an auto-increment resource id and a sub-id (incremented programmatically on each update) Table
CREATE TABLE `SomeEntity` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`subid` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`,`subid`),
Entity
private long id;
private int subid;
@Id
@Column(name = "id")
public long getId() {
return id;
}
@Id
@Column(name = "subid")
public int getSubid() {
return subid;
}
As in answer in linked post One available solution is to have a extra column concatenation of id and subid which allows fetching the assigned id on create.
Is there any information available on writing a custom SelectGenerator to achieve the purpose of incremental id and subid?
If i give away auto-increment for id.What would be a better way to achieve this?