I need to understand what relation should I have in case I have 3 tables. The first has id and the 2 others has id to refer to the id in the first table. All I found on the web is when having 2 tables – to use one-to-one relation. What is the relation in that case ?
For example, I have 3 tables: Table 1- User-info: Id First Name Last name
Table 2 – user-hobby: User-Id (this should refer to column Id in table User-info) Hobby Table 3 – user-job: User-Id (this should refer to column Id in table User-info) Job
User-info.hbm.xml: <id name="id" column="ID" unsaved-value="0"> <generator class="native" /> </id>
<property name="firstName" column="First_Name"/> <property name=" lastName" column="Last_name"/>
user-hobby.hbm.xml <id name="userId" column="ID"> <generator class="foreign"> <param name="property">id</param> </generator> </id>
<property name="hobby" column=" Hobby"/> <one-to-one name="id" class="com.entity.UserInfo" constrained="true"/>
user-hobby.hbm.xml <id name="userId" column="ID"> <generator class="foreign"> <param name="property">id</param> </generator> </id>
<property name="job" column=" Job"/> <one-to-one name="id" class="com.entity.UserInfo" constrained="true"/>
Am I missing something here? Should I declare something in User-info.hbm.xml ?
Thanking you in advance, Eli
|