丄諦啲仇魜ヤ
          如 果 敵 人 讓 你 生 氣 , 那 說 明 你 沒 有 勝 他 的 把 握!
          posts - 6,comments - 56,trackbacks - 1
          首先
               創(chuàng)建表(mssql)  及vo     

          person 表
                 id;(主鍵) int;
                 username  varchar;
                 password  varchar;
                   sex   varchar;
                 birthday  DateTime;
          *******************
          student表  
              id;(主鍵)
             
              grade  varchar;

          *******************
          teacher表
              id;(主鍵)
             schoolage varchar;

          /////////////////////******////////////////////////////////
          再創(chuàng)建VO
          Person 

          package wsq.po;

          import java.util.Date;
          public class Person implements java.io.Serializable {
           private static final long serialVersionUID = -4431851578811178858L;

           private Integer id;

           private String username;

           private String password;

           private String sex;

           private Date birthday;
           public Person() {
           }
           public Person(String username, String password, String sex, Date birthday) {
            this.username = username;
            this.password = password;
            this.sex = sex;
            this.birthday = birthday;
           }

           public Integer getId() {
            return this.id;
           }

           public void setId(Integer id) {
            this.id = id;
           }

           public String getUsername() {
            return this.username;
           }

           public void setUsername(String username) {
            this.username = username;
           }

           public String getPassword() {
            return this.password;
           }

           public void setPassword(String password) {
            this.password = password;
           }

           public String getSex() {
            return this.sex;
           }

           public void setSex(String sex) {
            this.sex = sex;
           }

           public Date getBirthday() {
            return this.birthday;
           }

           public void setBirthday(Date birthday) {
            this.birthday = birthday;
           }

          }

           Student 

              注意id屬性沒有了

          package wsq.po;
          public class Student extends Person implements java.io.Serializable {

           private static final long serialVersionUID = -2981420482383402755L;
           private String grade;
           public Student() {
           }

           public String getGrade() {
            return this.grade;
           }

           public void setGrade(String grade) {
            this.grade = grade;
           }

          }

          Teacher 
            

          package wsq.po;

          public class Teacher extends Person implements java.io.Serializable {


           private static final long serialVersionUID = -8404469876025711535L;

           private String schoolage;

            public Teacher() {
           }

           public String getSchoolage() {
            return this.schoolage;
           }

           public void setSchoolage(String schoolage) {
            this.schoolage = schoolage;
           }

          }
          ////////////////////****************/////////////////////////
          最關(guān)鍵的就是配置了
            <?xml version="1.0" encoding="utf-8"?>
          <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
          <!--
              Mapping file autogenerated by MyEclipse Persistence Tools
          -->
          <hibernate-mapping>
              <class name="wsq.po.Person" table="person" schema="dbo" catalog="J2EE">
                  <id name="id" type="java.lang.Integer">
                      <column name="id" />
                      <generator class="increment" />
                  </id>
                  <property name="username" type="java.lang.String">
                      <column name="username" length="20" not-null="true" />
                  </property>
                  <property name="password" type="java.lang.String">
                      <column name="password" length="20" not-null="true" />
                  </property>
                  <property name="sex" type="java.lang.String">
                      <column name="sex" length="2" not-null="true" />
                  </property>
                  <property name="birthday" type="java.util.Date">
                      <column name="birthday" length="8" not-null="true" />
                  </property>
               <joined-subclass name="wsq.po.Student" table="student">
                   <key column="id"/>
                   <property name="grade" type="java.lang.String" column="grade" />
               </joined-subclass>
               <joined-subclass name="wsq.po.Teacher" table="teacher">
                   <key column="id"/>
                  <property name="schoolage" type="java.lang.String" column="schoolage" />
               </joined-subclass>
              </class>
          </hibernate-mapping>

          posted on 2007-09-02 09:30 Crying 閱讀(393) 評論(0)  編輯  收藏 所屬分類: hibernate
          主站蜘蛛池模板: 台中市| 庄河市| 光山县| 商河县| 荥阳市| 淮安市| 钦州市| 迁西县| 东明县| 临西县| 永新县| 平安县| 天门市| 措勤县| 徐水县| 阿荣旗| 锡林浩特市| 时尚| 黄梅县| 新河县| 文水县| 石河子市| 丽水市| 湖南省| 百色市| 萍乡市| 瑞金市| 华安县| 尚义县| 旺苍县| 图们市| 大兴区| 德江县| 鸡东县| 桑植县| 澎湖县| 伊金霍洛旗| 浪卡子县| 宁化县| 鹤峰县| 阳江市|