[hibernate-dev] Modeling natural-id on entity in XML
Steve Ebersole
steve at hibernate.org
Tue Feb 18 02:32:27 EST 2014
As we move to 5.0 and the new unified XML format I'd like to revisit the
ways we have mapped certain things historically in hbm.xml and improve upon
them when possible. At the moment I am looking at mapping of natural ids.
In hbm.xml the form was to wrap the attributes making up the natural id in
a grouping:
<class name="Person">
<id name="id"/>
<natural-id>
<property name="lastName"/>
<property name="firstName"/>
</natural-id>
...
</class>
which can become unwieldy if you want these values to exist in other
groupings.
So, as we transition to the unified XML I wonder if something like this
isn't a better model:
<entity class="Person">
<id name="id"/>
<basic name="lastName" natural-id="true" />
<basic name="firstName" natural-id="true" />
...
</class>
I would like to expose the mutability and cache config aspects of natural
ids in the XML as well. Logically these should apply to the group as a
whole. How do y'all feel about:
<entity class="Person">
<id name="id"/>
<natural-id mutable="true|false" cache-region="ABC" />
<basic name="lastName" natural-id="true" />
<basic name="firstName" natural-id="true" />
...
</class>
?
More information about the hibernate-dev
mailing list