Java 및 Hibernate를 사용하여 문서 수정 추적 시스템을 구현하려고합니다. 문서에 대한 모든 모드는 autor 및 timestamp와 함께 저장됩니다. 문서 작성자를 얻으려면 가장 빠른 모드를 만들어야합니다. 여기있다 : 나는 적어도 엔티티에서 getAutor()
방법에서 쿼리를 실행하지 않는 게 좋을쿼리에 의해 정의 된 Hibernate 엔티티 프로퍼티
@Entity
@Table(name="Modifications")
public class Modification
{
String autor;
Date dateTime;
Document document;
@ManyToOne
public Document getDocument() {
...
}
// Author of this mod
@Column(name="Autor")
public String getAutor() {
...
}
// and other properties
}
@Entity
@Table(name="Documents")
public class Document
{
private List<Modification> modifications;
@OneToMany(mappedBy="document")
public List<Modification> getModifications() {
...
}
// this property is question about. How should I implement this with hibernate?
//I don't want to store "autor" field in entity,
//it should be determined with query to modifications table.
// But I can't find any example of defining properties this way...
// So I need your advices :)
public String getAutor() {
...
}
// other properties
}