I need to create a one-to-one relationship between the Device table and the Status table based on the Device.hostname and Status.hostname relationship.
The Status table is populated by an external application and is readonly to Hibernate.
Is one-to-one the way to do it? All of the documentation seems to point to the fact that one-to-one only supports the PK on the mapped class.
TIA
Hibernate version: 2.0
Mapping documents:
Device
Code:
<hibernate-mapping>
<class name="Device" table="device">
<cache usage="read-write"/>
<id name="id" column="id" type="java.lang.Long" unsaved-value="null">
<generator class="hilo">
<param name="table">hi_value</param>
<param name="column">next_value</param>
<param name="max_lo">100</param>
</generator>
</id>
<property name="hostname" type="java.lang.String" column="hostname" length="255" not-null="true" unique="true"/>
</class>
</hibernate-mapping>
Status
Code:
<hibernate-mapping default-cascade="none">
<class name="Status"
table="status">
<id name="hostname" type="java.lang.String" column="host_name">
<generator class="assigned"/>
</id>
<property name="hostStatus" type="int" column="host_status" not-null="true" length="1"/>
</class>
</hibernate-mapping>
Name and version of the database you are using: MySQL 3.21.x