posts - 325,  comments - 25,  trackbacks - 0
一个持久化类是另一个持久化类的组成部分
顾客表: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

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


网站导航:
 
<2008年5月>
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567

 

长春语林科技欢迎您!

常用链接

留言簿(6)

随笔分类

随笔档案

文章分类

文章档案

相册

收藏夹

搜索

  •  

最新评论

阅读排行榜

评论排行榜