These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: need help on an one-to-one problem.
PostPosted: Mon Nov 06, 2006 3:41 pm 
Newbie

Joined: Mon Nov 06, 2006 3:00 pm
Posts: 2
Location: Maryland
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>

_________________
~ShoKu~


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.