真善美

勇于承担责任; 如果你做不到,要提前跟别人说明,不要等到事情发生后再解释。

  BlogJava :: 首页 ::  :: 联系 :: 聚合  :: 管理 ::
  55 随笔 :: 0 文章 :: 29 评论 :: 0 Trackbacks
 1 <?xml version="1.0"?>
 2 <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
 3 "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
 4 <!-- 
 5     Mapping file autogenerated by MyEclipse - Hibernate Tools
 6 -->
 7 <hibernate-mapping>
 8     <!-- 类名与表名映射 -->
 9     <class name="com.cvicse.ks.mamis.common.orm.MaMaperson" table="ma_maperson">
10         <!-- id与主键映射 -->
11         <id name="id" type="java.lang.Integer">
12             <column name="id" />
13             <generator class="assigned" />
14         </id>
15         <!-- 类的属性与表格字段名的映射 -->
16         <!-- 也可以这样写<property name="pqa" column="name" type="java.lang.String"> -->
17         <property name="pqa" type="java.lang.String">
18             <column name="pqa" length="6" />
19         </property>
20         <property name="pma" type="java.lang.String">
21             <column name="pma" length="6" />
22         </property>
23         <property name="ptm" type="java.lang.String">
24             <column name="ptm" length="6" />
25         </property>
26         <set name="maModbaseinfos" inverse="true">
27             <key>
28                 <column name="pid" />
29             </key>
30             <one-to-many class="com.cvicse.ks.mamis.common.orm.MaModbaseinfo" />
31         </set>
32     </class>
33 </hibernate-mapping>
34 
映射文件中主要包括三个部份:类名与表名的映射、id与数据库表主键字段的映射、类属性与表字段的映射。
 1 package com.cvicse.ks.mamis.common.orm;
 2 
 3 import java.util.Date;
 4 import java.util.HashSet;
 5 import java.util.Set;
 6 
 7 import com.cvicse.ks.mamis.common.util.CalendarUtil;
 8 
 9 /**
10  * MaMaperson generated by MyEclipse - Hibernate Tools
11  */
12 
13 public class MaMaperson implements java.io.Serializable {
14 
15     // Fields
16 
17     private Integer id;
18 
19     private String pqa;
20 
21     private String pma;
22 
23     private String ptm;
24 
25     private Set maModbaseinfos = new HashSet(0);
26 
27     // Constructors
28 
29     /** default constructor */
30     public MaMaperson() {
31     }
32 
33     /** full constructor */
34     public MaMaperson(String pqa, String pma, String ptm, Set maModbaseinfos) {
35         this.pqa = pqa;
36         this.pma = pma;
37         this.ptm = ptm;
38         this.maModbaseinfos = maModbaseinfos;
39     }
40 
41     // Property accessors
42 
43     public Integer getId() {
44         return this.id;
45     }
46 
47     public void setId(Integer id) {
48         this.id = id;
49     }
50 
51     public String getPqa() {
52         return this.pqa;
53     }
54 
55     public void setPqa(String pqa) {
56         this.pqa = pqa;
57     }
58 
59     public String getPma() {
60         return this.pma;
61     }
62 
63     public void setPma(String pma) {
64         this.pma = pma;
65     }
66 
67     public String getPtm() {
68         return this.ptm;
69     }
70 
71     public void setPtm(String ptm) {
72         this.ptm = ptm;
73     }
74 
75     public Set getMaModbaseinfos() {
76         return this.maModbaseinfos;
77     }
78 
79     public void setMaModbaseinfos(Set maModbaseinfos) {
80         this.maModbaseinfos = maModbaseinfos;
81     }
82 }

必须有构造方法。id的生成方式。

posted on 2007-08-30 17:29 真善美 阅读(301) 评论(0)  编辑  收藏 所属分类: Hibernate学习