丄諦啲仇魜ヤ
如 果 敌 人 让 你 生 气 , 那 说 明 你 没 有 胜 他 的 把 握!
posts - 6,comments - 56,trackbacks - 1
  创建表:
     PersonOne
         id;   role;   username;   password; sex;  birthday;   grade;  schoolage;

  ////////////////////// /****///////////////****///////////////////********/////////////////////////////
VO :

 

package wsq.po;

import java.util.Date;

public class PersonOne implements java.io.Serializable {

 private static final long serialVersionUID = 3694568337955384021L;

 private Integer id;

 private String role;

 private String username;

 private String password;

 private String sex;

 private Date birthday;

// private String grade;
// private String schoolage;

 public PersonOne() {
 }

 
 public PersonOne(String role, String username, String password, String sex,
   Date birthday, String grade, String schoolage) {
  this.role = role;
  this.username = username;
  this.password = password;
  this.sex = sex;
  this.birthday = birthday;
  //this.grade = grade;
  //this.schoolage = schoolage;
 }
 public Integer getId() {
  return this.id;
 }

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

 public String getRole() {
  return this.role;
 }

 public void setRole(String role) {
  this.role = role;
 }

 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;
 }

// public String getGrade() {
//  return this.grade;
// }
//
// public void setGrade(String grade) {
//  this.grade = grade;
// }
//
// public String getSchoolage() {
//  return this.schoolage;
// }
//
// public void setSchoolage(String schoolage) {
//  this.schoolage = schoolage;
// }

}


Student:  
    

package wsq.po;

public class Student extends PersonOne implements java.io.Serializable {

 private static final long serialVersionUID = -2981420482383402755L;

 
 private String grade;

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

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

}

Teacher :
package wsq.po;

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


 private static final long serialVersionUID = -8404469876025711535L;

 private String schoolage;

 public String getSchoolage() {
  return schoolage;
 }

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

配置:

<?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.PersonOne" table="personOne" schema="dbo"
  catalog="J2EE">
  <id name="id" type="java.lang.Integer">
   <column name="id" />
   <generator class="increment" />
  </id>
            <!--  important   -->
  <discriminator column="role" type="java.lang.String"/>

  
  <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="5" not-null="true" />
  </property>
  <property name="birthday" type="java.util.Date">
   <column name="birthday" length="23" not-null="true" />
  </property>
  
  
  
  <subclass name="wsq.po.Student" discriminator-value="1">
   <property name="grade" column="grade" type="java.lang.String" />
  </subclass>
  <subclass name="wsq.po.Teacher" discriminator-value="2">
   <property name="schoolage" column="schoolage" type="java.lang.String" />
  </subclass>

 </class>
</hibernate-mapping>


 


posted on 2007-09-02 09:54 Crying 阅读(1047) 评论(0)  编辑  收藏 所属分类: hibernate

只有注册用户登录后才能发表评论。


网站导航: