java - Hibernate entity property defined by a query -


I try to implement the document modification tracking system with Java and Hibernate. The document is saved with every modern autor and timestamp. To get the creator of the document, I need to mod mod at the earliest. Here it is:

  @Antity @Table (name = "modifications") Public class revision {String autor; Date; Document document; @ManyToOne public document getDocument () {...} // Author of this mod @ column (name = "author") public string getAutor () {...} // and other attributes} @tainty (name = "Document") public class document {private list & lt; Research & gt; Amendments; @OneToMany (mapped = "document") public list & lt; Research & gt; GetModifications () {...} // The question about this property is how do I apply it with Hibernate? // I do not want to store the "autor" field in the unit, // it should be determined with the query from the modifications table. // But I'm not getting any examples of defining properties ... // so I need your advice :) Public string getAutor () {...} // Other properties}  < / Pre>  

I do not have at least the power in the getAutor () method. IMO entites itself should not execute questions.

So why do not you provide a way in some service / DAO which provides the author as necessary? Alternatively, you want to create a transient field for the author in the document and fill it with Dao. In this way, you only need to load the author once and use the information multiple times.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -