Java Reference
In-Depth Information
The required order and cardinality of the child elements of <class> are as follows:
(meta*,
subselect?,
cache?,
synchronize*,
comment?,
tuplizer*,
(id | composite-id),
discriminator?,
(version | timestamp)?,
(property | many-to-one | one-to-one | component | dynamic-component |
properties | any | map | set | list | bag | idbag |
array | primitive-array)*,
((join*, subclass*) | joined-subclass* | union-subclass*),
loader?,
sql-insert?,
sql-update?,
sql-delete?,
filter*
resultset,
(query | sql-query)
)
The <id> Element
All entities need to define their primary key in some way. Any class directly defined by the
<class> element (not a derived or component class) must therefore have an <id> or a
<composite-id> element to define this (see Table 7-4). Note that while it is not a requirement
that your class implementation itself should implement the primary key attribute, it is cer-
tainly advisable. If you cannot alter your class design to accommodate this, you can instead
use the getIdentifier() method on the Session object to determine the identifier of a per-
sistent class independently.
Table 7-4. The <id> 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. The value from
the <hibernate-mapping> element will be inherited if
this is not specified.
column
The name of the column in the table containing the
primary key. The value given in the name attribute
will be used if this is not specified.
length
The column length to be used.
Search WWH ::




Custom Search