title: JPA or Hibernate to generate a (non primary key) column value, not starting from 1
body: <p>I want a JPA/Hibernate (preferably JPA) annotation that can generate the value of a column, that is not a primary key and it doesn't start from 1.</p>
  
  <p>From what I have seen JPA cannot do that with @GeneratedValue and @SequenceGenerator and @TableGenerator. Or with anything else.</p>
  
  <p>I have seen a <a href="https://stackoverflow.com/questions/277630/hibernate-jpa-sequence-non-id">solution</a> with an extra table, which I find is not elegant.</p>
  
  <p>I can live with a Hibernate annotation, because I already have hibernate annotations.</p>
  
  <p>I want to use @Generated but I cannot make it work and people <a href="https://stackoverflow.com/a/283603/616553">claim</a> that it is possible.</p>
  
  <pre><code>@Generated(GenerationTime.INSERT)
  private long invoiceNumber;//invoice number
  </code></pre>
  
  <p>Update: an extra requirement, if the transaction is rolled back, we can't have a gap in the numbering.
  Anyone?</p>