title: How to override Hibernate Id generation for strategy GenerationType.TABLE
body: <p>I need to override the values that are generated from Hibernate for an entity when the selected strategy is <code>GenerationType.TABLE</code>.</p>
  
  <p>One example of needing to override the generated value is when a value for the id field is already supplied by some other layer of the application, I don't want Hibernate to generate a new value, but instead use the supplied one.</p>
  
  <p>Here is the id part of the entity (AdvEntity)</p>
  
  <pre><code>@TableGenerator(name = "AID_SERIAL",
                  table = "serial",
                  pkColumnName="name", pkColumnValue = "adv",
                  valueColumnName = "no", allocationSize = 1)
  @GeneratedValue(strategy= GenerationType.TABLE, generator="AID_SERIAL")
  @Column(name = "AID")
  @Id
  public Integer getAid() {
      return aid;
  }
  </code></pre>
  
  <p>I have found many answers that describe how to solve the problem when <code>GenerationType.SEQUENCE</code> is used, but couldn't locate any for <code>GenerationType.TABLE</code></p>