一个持久化类是另一个持久化类的组成部分
顾客表: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
长春语林科技 阅读(291)
评论(0) 编辑 收藏 所属分类:
hibernate