I am try to create table information_table contains the address and phone information. And a join table staff_record that has a info_record_id column, which reference to information_table.info_record_id, contains the current address record and another column one-to-one to the information_record table contain the previous address. However, the column for previous address is not shown in the table. I am using Hibernate2. Does anybody know why or have a solution to it? Thank you very much.
Here are my classes and .hbm.xml:
StaffRecordDao.java
Code:
class StaffRecordDao extends InfoRecordDao {
private String fname;
private String lname;
private InfoRecordDao previousAddress;
... getters and setters are here.
}
class InfoRecordDao {
private Long id;
private String address;
private String city;
private String state;
private String zipcode;
private String phone;
private Integer totalYears;
... getters and setters are here.
}
Here is my *.hbm.xml mapping
Code:
<hibernate-mapping>
<class
name="com.test.dao.InfoRecordDao"
table="information_record"
proxy="com.test.dao.InfoRecordDao"
dynamic-update="false"
dynamic-insert="false"
>
<id
name="id"
column="info_record_id"
type="java.lang.Long"
>
<generator class="identity">
<param name="identity">s_key_id_code</param>
</generator>
</id>
<property
name="address"
type="java.lang.String"
update="true"
insert="true"
column="address"
/>
<property
name="city"
type="java.lang.String"
update="true"
insert="true"
column="city"
/>
<property
name="state"
type="java.lang.String"
update="true"
insert="true"
column="state"
/>
<property
name="zipcode"
type="java.lang.String"
update="true"
insert="true"
column="zip_code"
/>
<property
name="phone"
type="java.lang.String"
update="true"
insert="true"
column="phone_number"
/>
<property
name="totalYears"
type="java.lang.Integer"
update="true"
insert="true"
column="total_years"
/>
<joined-subclass
name="com.test.dao.StaffRecordDao"
table="staff_record"
dynamic-update="false"
dynamic-insert="false"
proxy="com.test.dao.IStaffRecordDao"
>
<key
column="info_record_id"
/>
<property
name="fname"
type="java.lang.String"
update="true"
insert="true"
column="first_name"
/>
<property
name="lname"
type="java.lang.String"
update="true"
insert="true"
column="last_name"
/>
<one-to-one
name="previousAddress"
class="com.test.dao.InfoRecordDao"
cascade="all"
outer-join="auto"
constrained="true"
/>
</joined-subclass>
</class>
</hibernate-mapping>