no
no
BlogJava
首页
新随笔
联系
聚合
管理
6 Posts :: 2 Stories :: 0 Comments :: 0 Trackbacks
常用链接
我的随笔
我的评论
我的参与
留言簿
(1)
给我留言
查看公开留言
查看私人留言
随笔档案
2008年6月 (6)
文章档案
2008年6月 (2)
搜索
最新评论
阅读排行榜
1. TSysUserDAO(221)
2. struts(220)
3. applicationContext(204)
4. hbm(165)
5. TSysUserService(164)
评论排行榜
1. struts(0)
2. TSysUserDAO(0)
3. hbm(0)
4. TSysUser(0)
5. applicationContext(0)
TSysUserDAO
1
public
class
TSysUserDAO
extends
HibernateDaoSupport
implements
ITSysUserDAO
{
2
//
插入
3
public
void
addUser(TSysUser transactceinstance)
{
4
getHibernateTemplate().save(transactceinstance);
5
}
6
//
删除
7
public
void
deleteUser(TSysUser persistenceinstance)
{
8
getHibernateTemplate().delete(persistenceinstance);
9
}
10
//
更新
11
public
void
updateUser(TSysUser user)
{
12
getHibernateTemplate().update(user);
13
}
14
//
查询
15
public
TSysUser queryById(String id)
{
16
return
(TSysUser)getHibernateTemplate().get(TSysUser.
class
, id);
17
}
18
public
List queryAll()
{
19
String queryString
=
"
from TSysUser
"
;
20
return
getHibernateTemplate().find(queryString);
21
}
22
public
List findByProperty(String propertyName, Object value)
{
23
//
TODO Auto-generated method stub
24
String queryString
=
"
from TSysUser as user where user.
"
+
propertyName
+
"
=?
"
;
25
return
getHibernateTemplate().find(queryString, value);
26
}
27
public
List queryById1(Object id)
{
28
return
findByProperty(SZ_USER_ID, id);
29
}
30
public
List queryByName(Object name)
{
31
return
findByProperty(SZ_USER_NAME, name);
32
}
33
public
List queryByOrgan(Object organ)
{
34
return
findByProperty(SZ_ORGAN, organ);
35
}
36
public
List queryByState(Object state)
{
37
return
findByProperty(SZ_REG_STATE, state);
38
}
39
public
List queryByBirthday(Object birthday)
{
40
//
TODO Auto-generated method stub
41
return
findByProperty(SZ_BIRTHDAY, birthday);
42
}
43
public
List queryByEducation(Object education)
{
44
//
TODO Auto-generated method stub
45
return
findByProperty(SZ_EDU_EXPERIENCE , education);
46
}
47
public
List queryByEmployeeType(Object employeeType)
{
48
//
TODO Auto-generated method stub
49
return
findByProperty(SZ_EMPLOYEE_TYPE, employeeType);
50
}
51
public
List queryBySchool(Object school)
{
52
//
TODO Auto-generated method stub
53
return
findByProperty(SZ_GRADUATION_SCHOOL, school);
54
}
55
public
List queryBySex(Object sex)
{
56
//
TODO Auto-generated method stub
57
return
findByProperty(SZ_SEX, sex);
58
}
59
public
List queryByUserRole(Object role)
{
60
//
TODO Auto-generated method stub
61
return
findByProperty(SZ_USER_ROLE, role);
62
}
63
public
List
<
TSysUser
>
findByList(List
<
Object[]
>
conditions)
{
64
Criteria crit
=
getHibernateTemplate().getSessionFactory().openSession().createCriteria(TSysUser.
class
);
65
for
(Object[] objects: conditions)
{
66
Criterion criterion
=
null
;
67
String field
=
(String)objects[
0
];
68
Object value
=
objects[
1
];
69
if
(
!
value.equals(
""
))
{
70
String orp
=
(String)objects[
2
];
71
if
(orp.equals(
"
normal
"
))
72
criterion
=
Expression.eq(field, value);
73
if
(orp.equals(
"
like
"
))
74
criterion
=
Expression.like(field,
"
%
"
+
value
+
"
%
"
);
75
crit.add(criterion);
76
}
77
78
}
79
return
crit.list();
80
}
81
public
List
<
TSysUser
>
fingByExample(TSysUser instance)
{
82
return
getHibernateTemplate().findByExample(instance);
83
}
84
public
TSysUser findById(String id)
{
85
86
TSysUser user
=
(TSysUser) getHibernateTemplate().get(
"
com.hgs.cmb.hibernate.vo.TSysUser
"
, id);
87
return
user;
88
89
}
90
public
boolean
insertUser(TSysUser user)
{
91
92
if
(
this
.findById(user.getSzUserId())
==
null
)
{
93
94
getHibernateTemplate().save(user);
95
return
true
;
96
}
97
return
false
;
98
99
}
100
public
boolean
login(TSysUser user)
{
101
//
TODO Auto-generated method stub
102
return
false
;
103
}
104
public
String getProperty(TSysUser user,String property)
{
105
String[] values
=
user.getByProperty(property);
106
107
List
<
TSysDict
>
list
=
(List
<
TSysDict
>
)getHibernateTemplate().find(
"
from TSysDict as tsd where tsd.szDictClass=? and tsd.szDictCode=?
"
, values);
108
try
{
109
Iterator it
=
list.iterator();
110
if
(it.hasNext())
{
//
在使用容器时,必须要使用.hasNext()方法判断后再对容器进行操作,否则会报错NoSuchElementException
111
//
System.out.println("don't know if it's all right");
112
TSysDict sd
=
(TSysDict)it.next();
113
//
System.out.println("sure it's all right");
114
return
sd.getSzDictValue();
115
}
116
}
117
catch
(Exception e)
{
118
e.printStackTrace();
119
}
120
System.out.println(
"
shit, still null!
"
);
121
return
"
shit
"
;
122
}
123
public
String getUserRole(TSysUser user,String property)
{
124
String userRole
=
user.getSzUserRole();
125
switch
(Integer.parseInt(userRole))
{
126
case
00
:
return
"
系统管理员
"
;
127
case
01
:
return
"
分行管理员
"
;
128
case
02
:
return
"
支行管理员
"
;
129
case
03
:
return
"
普通用户
"
;
130
default
:
return
"
shit
"
;
131
}
132
}
133
public
String getRgeState(TSysUser user,String property)
{
134
String regState
=
user.getSzRegState();
135
switch
(Integer.parseInt(regState))
{
136
case
0
:
return
"
未审核
"
;
137
case
1
:
return
"
已审核
"
;
138
default
:
return
"
shit
"
;
139
}
140
}
141
public
List findAllUser()
{
142
return
getHibernateTemplate().find(
"
from TSysUser
"
);
143
}
144
public
void
changeUser(TSysUser user)
{
145
getHibernateTemplate().update(user);
146
}
147
public
void
saveUser(TSysUser user)
{
148
getHibernateTemplate().update(user);
149
}
150
}
posted on 2008-06-17 07:40
yasoo
阅读(221)
评论(0)
编辑
收藏
新用户注册
刷新评论列表
只有注册用户
登录
后才能发表评论。
网站导航:
博客园
IT新闻
Chat2DB
C++博客
博问
管理
Powered by:
BlogJava
Copyright © yasoo