我有两个具有多对一关系的类 documentlog 和 documentversion(主键:int doc_id 和 int docVersionID)。我使用了一个名为 CompundKey 的复合键类来管理复合主键。我需要自动增加 docversionID,但我不能这样做。你能在这方面帮助我吗?
@Entity
@Table(name = "Documentversion", schema = "DocumentManagement")
public class DocumentVersion implements Serializable {
private CompoundKey id;
private List<DocumentLog> documentLog;
@OneToMany(mappedBy="documentVersion", targetEntity=DocumentLog.class,
cascade ={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH})
public List<DocumentLog> getDocumentLog() {
return documentLog;
}
public void setDocumentLog(List<DocumentLog> 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;
}
}