title: Hibernate Entity with a primary id and a revision id
body: <p>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)</p>
  
  <pre><code>id 1 subid 0 
  id 1 subid 1
  id 1 subid 2
  id 2 subid 0
  </code></pre>
  
  <p>In a <a href="https://stackoverflow.com/questions/31362100/explain-behaviors-in-mapping-auto-incremented-composite-id-sequence-with-hiberna">post here</a> I tried with an auto-increment resource id and a sub-id (incremented programmatically on each update)
  Table</p>
  
  <pre><code> CREATE TABLE `SomeEntity` (
   `id` int(11) NOT NULL AUTO_INCREMENT,
   `subid` int(11) NOT NULL DEFAULT '0',
   PRIMARY KEY (`id`,`subid`),
  </code></pre>
  
  <p>Entity</p>
  
  <pre><code>private long id;
  private int subid;
  
  @Id
  @Column(name = "id")
  public long getId() {
      return id;
    }
  
    @Id
    @Column(name = "subid")
    public int getSubid() {
      return subid;
    }
  </code></pre>
  
  <p>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.</p>
  
  <p><strong>Is there any information available on writing a custom SelectGenerator  to achieve the purpose of incremental id and subid?</strong></p>
  
  <p><strong>If i give away auto-increment for id.What would be a better way to achieve this?</strong></p>