Java Reference
In-Depth Information
The child elements of the <property> element are as follows:
(meta*, (column | formula)*, type?)
Any element accepting a column attribute, as is the case for the <property> element, will
also accept <column> elements in its place. For an example, see Listing 7-2.
Listing 7-2. Using the <column> Element
<property name="message"/>
<column name="message" type="string"/>
</property>
This particular example does not really give us anything beyond the use of the column
attribute directly; but the <column> element comes into its own with custom types and some
of the more complex mappings that we will be looking into later in the chapter.
The <component> Element
The <component> element is used to map classes that will be represented as extra columns
within a table describing some other class. We have already discussed how components fit
in as a compromise between full entity types and mere value types.
The <component> element can take the attributes listed in Table 7-7.
Table 7-7. The <component> Attributes
Attribute
Values
Default
Description
access
Defines how the properties should be accessed:
through field (directly), through property (calling
the get/set methods), or through the name of a
PropertyAccessor class to be used
class
The class that the parent class incorporates by
composition
insert
true , false
true
Specifies whether creation of an instance of the class
should result in the column associated with this
attribute being included in insert statements
lazy
true , false
false
Defines whether lazy instantiation is used by default
for this mapped entity
name
The name of the attribute (component) to be
persisted
node
Specifies the name of the XML element or attribute
that should be used by the XML relational persist-
ence features
optimistic-lock
true , false
true
Specifies the optimistic locking strategy to use
unique
true , false
false
Indicates that the values that represent the compo-
nent must be unique within the table
update
true , false
true
Specifies whether changes to this attribute in
instances of the class should result in the column
associated with this attribute being included in
update statements
Search WWH ::




Custom Search