BlueSpace
思想有多遠,我們就能走多遠!
BlogJava
::
首頁
::
新隨筆
::
聯系
::
聚合
::
管理
posts - 0, comments - 5, trackbacks - 0
<
2025年5月
>
日
一
二
三
四
五
六
27
28
29
30
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
31
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.tkk7.com/beansoft
http://www.tkk7.com/sterning
http://www.tkk7.com/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的SessionManager
?
?1
import
?org.apache.commons.logging.Log;
?2
import
?org.apache.commons.logging.LogFactory;
?3
import
?org.hibernate.FlushMode;
?4
import
?org.hibernate.HibernateException;
?5
import
?org.hibernate.Session;
?6
import
?org.hibernate.SessionFactory;
?7
import
?org.hibernate.Transaction;
?8
import
?org.hibernate.cfg.Configuration;
?9
10
11
12
public
?
class
?SessionManager?
{
13
????
private
?
static
?Log?log?
=
?LogFactory.getLog(SessionManager.
class
);
14
????
private
?
static
?
final
?SessionFactory?sessionFactory;
15
????
/**?*/
/**
靜態塊:創建session?factory
*/
16
????
static
?
{
17
????????
try
?
{
18
????????????System.out.println(
"
數據映射初始化
begin
"
);
19
????????????Configuration?configure?
=
?
new
?Configuration().configure();
20
????????????sessionFactory?
=
configure.buildSessionFactory();
21
????????????
/**/
/*
URL?configFileURL?=
22
????????????????????SessionManager.class.getResource("/hibernate.cfg.xml");
23
????????????Configuration?configure?=?(new?Configuration()).configure(configFileURL);
*/
24
????????????System.out.println(
"
數據映射初始化
end
"
);
25
????????}
?
catch
?(Throwable?ex)?
{
26
????????????log.error(
"
Initial?SessionFactory?creation?failed.
"
,?ex);
27
????????????
throw
?
new
?ExceptionInInitializerError(ex);
28
????????}
29
????}
30
????
/**?*/
/**
獲取當前線程的session對象
*/
31
????
public
?
static
?Session?currentSession()?
throws
?HibernateException?
{
32
????????Session?s?
=
?sessionFactory.openSession();
33
????????s.setFlushMode(FlushMode.NEVER);
34
????????
return
?s;
35
????}
36
????
public
?
static
?Session?currentSessionFlush()?
throws
?HibernateException?
{
37
????????Session?s?
=
?sessionFactory.openSession();
38
????????s.setFlushMode(FlushMode.AUTO);
39
????????
return
?s;
40
????}
41
????
/**?*/
/**
關閉當前線程所在的session對象
*/
42
????
public
?
static
?
void
?closeSession(Session?s)?
throws
?HibernateException?
{
43
????????
if
?(s?
!=
?
null
)
{
44
????????????s.close();
45
????????}
46
????}
47
????
public
?
static
?SessionFactory?getSessionFactory()?
{
48
????????
if
(sessionFactory
!=
null
)
{
49
????????????
return
?sessionFactory;
50
????????}
51
????????
else
{
52
????????????System.out.println(
"
無效的factiory
"
);
53
????????????
return
?
null
;
54
????????}
55
????}
56
}
57
posted on 2007-09-03 09:23
crazy
閱讀(391)
評論(0)
編輯
收藏
所屬分類:
hibernate
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發表評論。
網站導航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
相關文章:
文章系統.Hibernate的一對多,多對一映射
tomcat數據源的配置
hibernate.cfg.xml的配置
hibernate的SessionManager
Powered by:
BlogJava
Copyright ©2025 crazy
主站蜘蛛池模板:
亚洲中文字幕无码久久2020
|
亚洲成色WWW久久网站
|
狠狠色香婷婷久久亚洲精品
|
91福利免费体验区观看区
|
国产成人亚洲精品狼色在线
|
亚洲阿v天堂在线2017免费
|
国产精品亚洲专区无码不卡
|
成人午夜大片免费7777
|
亚洲高清视频在线
|
永久在线毛片免费观看
|
青草久久精品亚洲综合专区
|
免费人成在线观看网站视频
|
青青视频免费在线
|
亚洲国产成人爱av在线播放
|
aa级女人大片喷水视频免费
|
亚洲午夜久久久久久久久久
|
特级无码毛片免费视频
|
国产性生交xxxxx免费
|
麻豆亚洲AV成人无码久久精品
|
免费人成毛片动漫在线播放
|
亚洲国产精品婷婷久久
|
久久99国产乱子伦精品免费
|
亚洲一级片在线播放
|
日本一区二区三区日本免费
|
曰韩无码AV片免费播放不卡
|
亚洲精品无码国产
|
成人免费在线看片
|
日韩亚洲人成网站
|
亚洲AV无码久久精品成人
|
亚洲人成在线免费观看
|
亚洲成av人片天堂网无码】
|
亚洲国产一区明星换脸
|
国产精品免费无遮挡无码永久视频
|
在线观看人成视频免费无遮挡
|
亚洲视频手机在线
|
国产免费啪嗒啪嗒视频看看
|
无码日韩精品一区二区免费暖暖
|
亚洲日韩国产精品乱-久
|
亚洲AV无码专区日韩
|
久久国产色AV免费看
|
国产亚洲女在线线精品
|