title: How can I use generated value within composite keys?
body: <p>I have two classes documentlog and documentversion(with primary keys: int doc_id and int docVersionID) with a many-to-one relationship. I used a composite key class called CompundKey to manage the compound primary key. I need to auto increment docversionID but I am not able to do that. Could you please help me in this regard?</p>
  
  <pre><code>@Entity
  @Table(name = "Documentversion", schema = "DocumentManagement")
  public class DocumentVersion implements Serializable { 
  
   private CompoundKey id;
   private List&lt;DocumentLog&gt; documentLog;
  
   @OneToMany(mappedBy="documentVersion", targetEntity=DocumentLog.class,  
     cascade ={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH})
   public List&lt;DocumentLog&gt; getDocumentLog() {
    return documentLog;
   }
   public void setDocumentLog(List&lt;DocumentLog&gt; documentLog) {
    this.documentLog = documentLog;
   }
  
   @EmbeddedId 
   @AttributeOverride(name="doc_Id", column=@Column(name="doc_Id") )
   public CompoundKey getId() {
    return id;
   }
   public void setId(CompoundKey id) {
    this.id = id;
   } 
  }
  </code></pre>