一個持久化類是另一個持久化類的組成部分
顧客表:clients
id int(4) <pk>
name varchar(20)
likeman varchar(20)
phone varchar(20)
province varchar(40)
city varchar(40)
street varchar(40)
zipcode char(8)
持久化類:
Clients:
public class Clients implements Serializable{
private Integer id;
private String name;
private String likeman;
private String phone;
private Address address;
public Clients(){
}
}
public class Address implements Serializable{
private String province;
private String city;
private String street;
private String zipcode;
private Clients client;
public Address(){
}
}
hbm.xml
<hibernate-mapping package="com.lhb.vo">
<class name="Clients" table="clients">
<id name="id" column="id" type="integer">
<generator class="native"/>
</id>
<property name="name" column="name" type="string"/>
<property name="likeman" column="likeman" type="string"/>
<property name="phone" column="phone" type="string/>
<component name="address" class="com.lhb.vo.Address">
<parent name="clients"/>
<property name="province" column="province" type="string"/>
<property name="city" column="city" type="string"/>
<property name="street" column="street" type="string"/>
<property name="zipcode" column="zipcode" type="string"/>
</component>
</class>
</hibernate-mapping>
posted on 2008-05-25 18:02
長春語林科技 閱讀(296)
評論(0) 編輯 收藏 所屬分類:
hibernate