WEB开发网
开发学院软件开发Java Hibernate各种映射关系总结 阅读

Hibernate各种映射关系总结

 2009-10-30 00:00:00 来源:WEB开发网   
核心提示: 5 继承mapping第一类继承映射1 对象模型AnimalprivateintidprivateStringnameprivateBooleansex--publicclassBirdextendsAnimalprivateintheight--publicclassPigextendsAni

5 继承mapping

第一类继承映射

1 对象模型

Animal 
private int id
private String name
private Boolean sex
--------------------------------------------------
public class Bird extends Animal 
private int height
--------------------------------------------------
public class Pig extends Animal
private int weight

2 mapping 文件

Xml代码

<?xml version="1.0"?> 
<!DOCTYPE hibernate-mapping PUBLIC 
 "-//Hibernate/Hibernate Mapping DTD 3.0//EN" 
 "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> 
<hibernate-mapping package="com.nintenyun.hibernate"> 
  <class name="Animal" table="t_animal" > 
   <id name="id" > 
    <generator class="native"/> 
   </id> 
   <discriminator column="type" type="string"></discriminator> 
   <property name="name"/> 
   <property name="sex"/> 
   <subclass name="Pig" discriminator-value="P"> 
    <property name="weight"/> 
   </subclass> 
   <subclass name="Bird" discriminator-value="B"> 
    <property name="height"/> 
   </subclass> 
  </class> 
  
 
  
</hibernate-mapping>

上一页  1 2 3 4 5 6 7  下一页

Tags:Hibernate 各种 映射

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接