one-to-one is mainly used for two tables sharing the same
primary key. For foreign key association, we normally use many-
to-one instead. However, with one-to-one is able to link up
tables via a foreign key. The above example can be mapped by
one-to-one as follows: <hibernate-mapping> <class name="Company"
table="Company" > <id name="id" /> <one-to-one
name="defaultContactPerson" property-ref="defaultContactPerson"
> <formula>id</formula> <formula>1</formula> </many-to-one>
</class> <class name="Person" > <id name="id" /> <properties
name="defaultContactPerson"> <property name="companyID" />
<property name="defaultFlag" /> </properties> </class>
</hibernate-mapping> formula can be used with a many-to-many
element for a special joining from relationship table to an
entity table, although this is not often The examples in this
article show most of the formula usage scenarios. When a
evaluation value is needed, the will appear in the select part
of the resulting SQL statement. And when a formula is used for
joini