Imagine a City to Postalcode relation mapping. (For simplicity using no foreign-keys)
<class name="CityToPostalcode" table="city_to_postalcode" catalog="database">
<id name="id" type="java.lang.Integer">
<column name="id" />
<generator class="identity" />
</id>
<property name="city" type="String">
<column name="city" not-null="true"/>
</property>
<property name="postalcode" type="Integer">
<column name="postalcode" not-null="true"/>
</property>
<properties name="businessKey" unique="true">
<property name="city"/>
<property name="postalcode"/>
</properties>
</class>
Is there a function in the framework to check if the unique key “businessKey” for a given combination is unique (also for single-column unique constraints)?
Maybe in combination of mapping “businessKey” to a class? (Similar to usage of composite-id)
It is just so much redundance to write the code for each table to check its business-key, if it definetly could be done automatic.
there is
natural Idwhich automaticly creates a unique constraint on schema creation and can be used to query for it more efficiently. in xmlnaturalids use the second level cache more efficient and from H4.1 on loading by naturalid uses the first level cache and can save roundtrips. Other than that natural ids are just like normal properties. you could however write a generic natural id checker