このコンテンツは選択した言語では利用できません。
18.2. XML Mapping Metadata
18.2.1. About XML Mapping Metadata リンクのコピーリンクがクリップボードにコピーされました!
リンクのコピーリンクがクリップボードにコピーされました!
A range of Hibernate mapping elements accept the
node
attribute. This lets you specify the name of an XML attribute or element that holds the property or entity data. The format of the node
attribute must be one of the following:
"element-name"
: map to the named XML element"@attribute-name"
: map to the named XML attribute"."
: map to the parent element"element-name/@attribute-name"
: map to the named attribute of the named element
For collections and single valued associations, there is an additional
embed-xml
attribute. If embed-xml="true"
, the default, the XML tree for the associated entity (or collection of value type) will be embedded directly in the XML tree for the entity that owns the association. Otherwise, if embed-xml="false"
, then only the referenced identifier value will appear in the XML for single point associations and collections will not appear at all.
Do not leave
embed-xml="true"
for too many associations, since XML does not deal well with circularity.
In this case, the collection of account ids is embedded, but not the actual account data. The following HQL query:
from Customer c left join fetch c.accounts where c.lastName like :lastName
from Customer c left join fetch c.accounts where c.lastName like :lastName
would return datasets such as this:
If you set
embed-xml="true"
on the <one-to-many>
mapping, the data might look more like this: