posts - 325,  comments - 25,  trackbacks - 0

1.数据表:
orders:订单表 customer:客户表
orders:
id  int(4)    <pk>
orderno  varchar(20)
moeny decimal(10,2)
customer_id int(4) <fk>

customer:
id int(4) <pk>
name varchar(20)
phone varchar(20)

2.pojo类
public class Customer implements Serilizable{
    private Integer id;
    private String name;
    private String phone;
    public Customer(){
    }
}
public class Orders implements Serilizable{
    private Integer id;
    private String orderno;
    private Double moeny;
    private Customer customer;
    public Orders(){
    }
}

3.hbm.xml
Orders.hbm.xml
<hibernate-mapping package="com.lhb.vo">
    <class name="Orders" table="orders">
        <id name="id" column="id" type="integer">
            <generator class="native"/>
        </id>
         <property name="moeny" column="moeny" type="double"/>
        <property name="orderno" column="orderno" type="string"/>
        <many-to-one name="customer_id" class="com.lhb.Customer" lazy="false" not-null="true"/>
    </class>
</hibernate-mapping>
Customer.hbm.xml

<hibernate-mapping package="com.lhb.vo">
   <class name="Customer" table="customer">
        <id name="id" column="id" type="integer">
                <generator class="native"/>
        </id>
        <property name="name" column="name" type="string"/>
        <proerty name="phone" column="phone" type="string"/>
    </class>
</hibernate-mapping>

 

posted on 2008-05-25 16:52 长春语林科技 阅读(175) 评论(0)  编辑  收藏 所属分类: hibernate

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


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

 

长春语林科技欢迎您!

常用链接

留言簿(6)

随笔分类

随笔档案

文章分类

文章档案

相册

收藏夹

搜索

  •  

最新评论

阅读排行榜

评论排行榜