The <properties> element allows the definition of a named, logical grouping of properties of a class. The most important use of the construct is that it allows a combination of properties to be the target of a property-ref. It is also a convenient way to define a multi-column unique constraint.
<properties
name="logicalName"
insert="true|false"
update="true|false"
optimistic-lock="true|false"
unique="true|false"
>
<property ...../>
<many-to-one .... />
........
</properties>
name: The logical name of the grouping - not an actual property name.
insert: Do the mapped columns appear in SQL INSERT s?
update: Do the mapped columns appear in SQL UPDATE s?
optimistic-lock (optional - defaults to true): Specifies that updates to these properties do or do not require acquisition of the optimistic lock. In other words, determines if a version increment should occur when these properties are dirty.
unique (optional - defaults to false): Specifies that a unique constraint exists upon all mapped columns of the component.
For example, if we have the following <properties> mapping:
<class name="Person">
<id name="personNumber"/>
...
<properties name="name"
unique="true" update="false">
<property name="firstName"/>
<property name="initial"/>
<property name="lastName"/>
</properties>
</class>
Then we might have some legacy data association which refers to this unique key of the Person table, instead of to the primary key:
<many-to-one name="person"
class="Person" property-ref="name">
<column name="firstName"/>
<column name="initial"/>
<column name="lastName"/>
</many-to-one>
We don't recommend the use of this kind of thing outside the context of mapping legacy data.