Where do I place my hibernate annotations?
Is this the line above my instance variable? Or before the recipient? Or before the setter? Or does it really matter?
Thank you very much
You place them in either the field < Hibernate on / em> or getter from annotation reference guide:
(...)
Do you explain the fields or methods, the type used by this type of area to be hibernate, or property, is required for EJB3 spec, that you declare an annotation on element type which Be, that if you use the property access, the field if you use field access should annotations mix in both areas and methods. The type of hibernate access type will be guessed by the status of @ id or @ embedded id.
You may also want to read about the annotation that override the force / access type (part of the hibernate annotation extension before NBT 3.5 and JPA 2.0
By default, access type of a class hierarchy is defined by the status of the @ id or embedded annotation if these annotations are on the field, then only the field For the sake of perseverance and state to the center of the field Is accessed by us. If any comment is on the recipient, then only mistakes are considered for perseverance and the state is transported through the recipient / Setter. It works well in practice and is a recommended approach.
NoteThe annotation should be consistent within a range of hierarchies (either on the region or property) to determine the default access type To be able to
However, in some cases, you need the following:
- Force access type
- Override the access type of a specific entity in the class hierarchy
- Override an embed type access type
The best use case is an embedable class, which Used by many organizations that can not use the same access type I In this case, it is better to implement the Access Type at the Embedded Class level.
(...)
Regarding the professionals and opposition of both styles, I suggest reading the following questions:
Comments
Post a Comment