Where the persistent attributes can be thought of as being logical mappings that indicate that a given
attribute is persistent, the physical annotation that is the companion annotation to the basic mapping
is the @Columnannotation. Specifying @Columnon the attribute indicates specific characteristics of the
physical database column that the object model is less concer ned about. In fact, the object model might
never even need to know to which column it is mapped, and the column name and physical mapping
metadata can be located in a separate XML file.
A number of annotation elements can be specified as part of @Column, but most of them apply only
to schema generation and will be covered later in the book. The only one that is of consequence is the nameelement, which is just a string that specifies the name of the column that the attribute has been mapped to. This is used when the default column name is not appropriate or does not apply to the schema being used. We can think of the nameelement of the @Columnannotation as a means of overriding the default column name that would have otherwise been applied. The example in Listing 4-7 shows how we can override the default column name for an attribute.
đang được dịch, vui lòng đợi..