BlueSpace
思想有多远,我们就能走多远!
BlogJava
::
首页
::
新随笔
::
联系
::
聚合
::
管理
posts - 0, comments - 5, trackbacks - 0
<
2024年11月
>
日
一
二
三
四
五
六
27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
1
2
3
4
5
6
7
留言簿
(1)
给我留言
查看公开留言
查看私人留言
我参与的团队
深圳Java俱乐部(0/0)
文章分类
ajax(1)
hibernate(4)
java(21)
javasrcipt(13)
mysql数据库(6)
spring
文章档案
2009年8月 (1)
2009年3月 (2)
2008年10月 (1)
2008年7月 (3)
2008年6月 (11)
2008年3月 (1)
2008年2月 (1)
2007年12月 (11)
2007年11月 (3)
2007年9月 (13)
相册
my photo
http://www.blogjava.net/beansoft
http://www.blogjava.net/sterning
http://www.blogjava.net/sterning
搜索
最新评论
1. re: xfire aegis转
评论内容较长,点击标题查看
--啊啊啊
2. re: xfire aegis转
itn
--吃饭会非常
3. re: distinct 与 order by
“select * from test group by name”这个SQL语句有问题,执行不了
--didi
4. re: java读取excel文件
good,so well,
--1111
5. re: 正则表达式,不区分大小写的替换
评论内容较长,点击标题查看
--新手。
文章系统.Hibernate的一对多,多对一映射
包含4个表,文章分类,文章,文章评论,文章评论回复
文章分为三级目录,bigSortID,secondSordID,smallSortID
1
<?
xml version="1.0"
?>
2
<!
DOCTYPE hibernate-mapping
3
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
4
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"
>
5
<
hibernate-mapping
>
6
<
class
name
="news.entity.ArticleSort"
dynamic-insert
="true"
dynamic-update
="true"
table
="art_sort"
>
7
<
id
name
="id"
type
="java.lang.Integer"
unsaved-value
="null"
>
8
<
column
name
="id"
not-null
="true"
/>
9
<
generator
class
="native"
/>
10
</
id
>
11
<
property
name
="sortName"
/>
12
<
property
name
="parentID"
/>
13
<
property
name
="createDate"
/>
14
<
property
name
="editDate"
/>
15
<
property
name
="orderBy"
/>
16
<
property
name
="descript"
/>
17
<
property
name
="editUser"
/>
18
<
property
name
="sortType"
/>
19
<
property
name
="isOpen"
/>
20
21
<!--
小类对应的文章
-->
22
<
set
name
="article"
inverse
="false"
lazy
="true"
order-by
=" id "
cascade
="none"
>
23
<
key
column
="smallSortID"
/>
24
<
one-to-many
class
="news.entity.Article"
/>
25
</
set
>
26
27
<!--
小类对应的大类
-->
28
<
many-to-one
insert
="false"
update
="false"
name
="parentBigSort"
29
class
= "news.entity.ArticleSort"
30
column
= "parentID"
/>
31
32
<!--
大类对应小类
-->
33
<
set
name
="smallSortSet"
inverse
="false"
lazy
="true"
order-by
=" id "
cascade
="none"
>
34
<
key
column
="parentID"
/>
35
<
one-to-many
class
="news.entity.ArticleSort"
/>
36
</
set
>
37
</
class
>
38
</
hibernate-mapping
>
39
40
41
<?
xml version="1.0"
?>
42
<!
DOCTYPE hibernate-mapping
43
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
44
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"
>
45
<
hibernate-mapping
>
46
<
class
name
="news.entity.Article"
dynamic-insert
="true"
dynamic-update
="true"
lazy
="false"
table
="art_news"
>
47
<
id
name
="id"
type
="java.lang.Integer"
unsaved-value
="null"
>
48
<
column
name
="id"
not-null
="true"
/>
49
<
generator
class
="native"
/>
50
</
id
>
51
<
property
name
="title"
/>
52
<
property
name
="subTitle"
/>
53
<
property
name
="author"
/>
54
<
property
name
="source"
/>
55
<
property
name
="url"
/>
56
<
property
name
="picUrl"
/>
57
<
property
name
="bigSortID"
/>
58
<
property
name
="secondSortID"
/>
59
<
property
name
="smallSortID"
/>
60
<
property
name
="content"
/>
61
<
property
name
="hitCount"
/>
62
<
property
name
="isPublish"
/>
63
<
property
name
="isTop"
/>
64
<
property
name
="createDate"
/>
65
<
property
name
="publishDate"
/>
66
<
property
name
="editDate"
/>
67
<
property
name
="editUser"
/>
68
<
property
name
="addUser"
/>
69
<!--
文章类别
-->
70
<
many-to-one
name
="articleSort"
insert
="false"
update
="false"
71
class
= "news.entity.ArticleSort"
column
= "secondSortID"
/>
72
</
class
>
73
</
hibernate-mapping
>
74
75
76
<?
xml version="1.0"
?>
77
<!
DOCTYPE hibernate-mapping
78
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
79
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"
>
80
<
hibernate-mapping
>
81
<
class
name
="news.entity.ArticleRemark"
dynamic-insert
="true"
dynamic-update
="true"
lazy
="false"
table
="art_remark"
>
82
<
id
name
="id"
type
="java.lang.Integer"
unsaved-value
="null"
>
83
<
column
name
="id"
not-null
="true"
/>
84
<
generator
class
="native"
/>
85
</
id
>
86
<
property
name
="newsId"
/>
87
<
property
name
="userName"
/>
88
<
property
name
="title"
/>
89
<
property
name
="contact"
/>
90
<
property
name
="checkFlag"
/>
91
<
property
name
="replyFlag"
/>
92
<
property
name
="creDate"
/>
93
<
property
name
="checkDate"
/>
94
<
property
name
="userIp"
/>
95
<
property
name
="checkUserId"
/>
96
<
many-to-one
name
="article"
insert
="false"
update
="false"
outer-join
="false"
97
class
= "news.entity.Article"
98
column
= "newsId"
/>
99
100
<
set
name
="remarkReply"
inverse
="true"
lazy
="true"
order-by
="replyTime desc"
where
=" flag=0 "
table
="art_remark_reply"
cascade
="all"
>
101
<
key
column
="remarkId"
/>
102
<
one-to-many
class
="news.entity.ArticleRemarkReply"
/>
103
</
set
>
104
105
</
class
>
106
</
hibernate-mapping
>
107
108
109
<?
xml version="1.0"
?>
110
<!
DOCTYPE hibernate-mapping
111
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
112
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"
>
113
<
hibernate-mapping
>
114
<
class
name
="news.entity.ArticleRemarkReply"
dynamic-insert
="true"
dynamic-update
="true"
lazy
="false"
table
="art_remark_reply"
>
115
<
id
name
="id"
type
="java.lang.Integer"
unsaved-value
="null"
>
116
<
column
name
="id"
not-null
="true"
/>
117
<
generator
class
="native"
/>
118
</
id
>
119
<
property
name
="remarkId"
/>
120
<
property
name
="content"
/>
121
<
property
name
="flag"
/>
122
<
property
name
="replyDate"
/>
123
<
property
name
="userName"
/>
124
<
property
name
="userID"
/>
125
</
class
>
126
</
hibernate-mapping
>
posted on 2007-09-07 10:09
crazy
阅读(194)
评论(0)
编辑
收藏
所属分类:
hibernate
新用户注册
刷新评论列表
只有注册用户
登录
后才能发表评论。
网站导航:
博客园
IT新闻
知识库
C++博客
博问
管理
相关文章:
文章系统.Hibernate的一对多,多对一映射
tomcat数据源的配置
hibernate.cfg.xml的配置
hibernate的SessionManager