文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>具体表继承

具体表继承

时间:2011-02-19  来源:魔战

Animal类:

package com.jzq.hibernate;

public class Animal {

 private int id;
 private String name;
 private String sex;
 public Animal(){}
 public int getId() {
  return id;
 }
 public void setId(int id) {
  this.id = id;
 }
 public String getName() {
  return name;
 }
 public void setName(String name) {
  this.name = name;
 }
 public String getSex() {
  return sex;
 }
 public void setSex(String sex) {
  this.sex = sex;
 }

}

Bird类:

package com.jzq.hibernate;

public class Bird extends Animal {

   private int height;
   public Bird(){}
   public int getHeight() {
 return height;
   }
 public void setHeight(int height) {
  this.height = height;
 }

}

Pig类:

package com.jzq.hibernate;

public class Pig extends Animal {

 private int height;
 public int getHeight() {
  return height;
 }
 public void setHeight(int height) {
  this.height = height;
 }
 public Pig(){}
}

配置文件:

<hibernate-mapping>
   <class name="Animal" package="com.jzq.hibernate">
      <id name="id">
          <generator class="native"/>
      </id>
      <property name="name"/>
      <property name="sex"/>
     
      <!-- 连接子类 Pig -->
      <joined-subclass name="Pig" table="t_pig">
         <key column="pid"/>
         <property name="weight"/>
      </joined-subclass>
     
      <!-- 连接子类 Bird -->
      <joined-subclass name="Bird" table="t_bird">
         <key column="bid"/>
         <property name="height"/>
      </joined-subclass>
     
   </class>
</hibernate-mapping>

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载