TA的每日心情 | 衰 2021-2-2 11:21 |
---|
签到天数: 36 天 [LV.5]常住居民I
|
项目开发中基类BaseDao的实现
/ ~8 r9 d$ n" C# w: S V% \- package cn.itcast.dao;
1 b" }: G5 a0 C) u" S - . G/ k; G) m1 a- L" ]. K
- import java.io.Serializable;
) G3 k5 s& o s( p - import java.util.List;: o; i+ A/ C, C: _, E# p& ?( L9 Z( X
* }4 E/ \+ T+ x7 y. u* T" Z- /**
8 R% l, Z/ Q6 J, z) M1 D - * BaseDao
( A. G2 Q7 N9 R1 m4 q+ v/ O0 J - * @author Administrator
`# t/ t3 \9 ^7 w9 O' k* B0 L - *2 J9 ~- z. p! c5 p) g8 {& i
- * @param <T>
3 M( g% O+ l. X; h+ @5 f. | - */, N+ q6 n1 \$ l/ h/ t. D3 m
- public interface BaseDao<T> {
; t9 T4 p+ q" I# d' c - /** 0 f# ^' ~7 A, z; t6 D3 ?0 l
- * 保存一个对象
* S( o% |& N: j8 \7 [" n Y1 u7 U - * 1 o9 r d7 y4 s% Z
- * @param o
4 y% V& @$ x' c8 p- U/ B - * @return ; a2 j, g1 [* K: z
- */
6 E6 f1 ^/ V6 e4 k) Q- z9 T - public Serializable save(T o); % |0 w4 u- Q: z! r7 p O; a5 Q- k% Y
-
9 Q7 t. v, e# K0 K. ^ - /**
5 Y7 Y6 H6 u, H - * 删除一个对象 3 U: W$ }/ x6 N3 L9 q" k
- * ( l2 h( m9 a9 q0 c/ t
- * @param o
" k; K$ W3 z5 ~* D) A6 t5 q - */ & {5 |& x" j- W9 t
- public void delete(T o); / t! N3 z8 }% v3 U6 g
- # S' v) `) M$ P- n2 h Y
- /** ( I/ I' ^7 v5 f) @8 x; P2 ^" p" C1 ~
- * 更新一个对象
, H- z6 c3 R5 d1 Z% { - * % d% t: q: l7 B5 Q2 a. R& @
- * @param o
0 Z# f5 D) m; l6 d$ A5 x0 w1 [# t - */ % t. d/ X4 Q4 z
- public void update(T o);
' Q0 u8 a7 q- G% e -
7 h, m6 X' w; N, K" x- I h - /** # j/ m6 \& m i$ |; A" V
- * 保存或更新对象
1 C8 c. J Y' u3 B2 h - *
" s2 v, g* l7 Z+ H - * @param o 0 y% J7 K8 E, V
- */ ' m8 P* L/ h9 ~ ]3 N. ^7 x6 Y
- public void saveOrUpdate(T o);
6 R% g, t, z. Y4 k -
" E. E* i3 g1 r" X1 _3 G - /** 6 Y" R) ~& H* C# S8 e7 i! g: B& J
- * 查询 ) G" j7 o& c9 w- y8 d4 z
- *
1 p0 u0 D( t& o3 E" S, ] - * @param hql " O; h* V( J# F7 T! M2 N/ o
- * @return 3 g/ P/ p, t1 m: o. R% k
- */
' }+ x& L2 o( |% L( g$ s - public List<T> find(String hql); . t m5 i/ y0 i
- ' T) D; {' T" D8 g% j- _6 c
- /** ( A) c$ H7 ?9 \. J
- * 查询集合 # I+ D% I. o' o2 d1 }
- *
# h9 N. g: M1 w: X6 d/ L. ]9 O6 i; | - * @param hql
% w; L- l. ?! x9 p) u - * @param param
# n% \( m0 X" Y, _ - * @return $ i% ~- p3 q% H) R. y3 P( e
- */ 0 N1 b( o* ]5 C {* U
- public List<T> find(String hql, Object[] param); ( c$ x5 ^! w" s; o/ b, m" o
- % C5 y. ?- Z* E) o
- /**
" v. p" @9 w7 c3 `' j9 n) M: n - * 查询集合 8 ]5 n. i5 X: x" f
- *
C1 q( A0 v$ k! g8 u4 ~1 N - * @param hql
: E& e6 o) `, a6 G. w# l+ U - * @param param
. x5 j3 f! m O8 }' u" p - * @return ' Z5 O) q4 h: N$ ?5 p
- */ ) h' P7 @ w, \' ^- { w; p: y: X. _$ }
- public List<T> find(String hql, List<Object> param); ( @1 e3 d) @8 U- d: O7 G
-
2 @* y x$ i; D$ l9 z! \ - /** " p7 c( }+ j+ S) g; D
- * 查询集合(带分页)
. p" }2 I+ _; o5 E2 t - *
7 U$ _6 l% S. ?5 ~$ R - * @param hql . R6 \3 n* w+ ]7 ?6 S8 h, R: K
- * @param param & X f: t+ o i" ?. ]( S
- * @param page
3 D9 M$ |9 G/ ?5 `/ E - * 查询第几页
8 p% K0 |' `9 ^7 Q7 g- R - * @param rows
0 ]- A7 e. r2 d0 m# S - * 每页显示几条记录 + j ?+ i* \$ _; I c2 c C
- * @return
9 z, |7 \" t6 \7 l7 L2 q' f - */
) q! T F2 b/ q5 v d - public List<T> find(String hql, Object[] param, Integer page, Integer rows);
# {/ H3 e( ]. Y% s -
% v, W3 j# ^% `9 D6 n' P - /**
3 }+ s& T) [& L1 r4 L n1 b7 S1 g# U - * 查询集合(带分页) ! W) H3 k. V! j
- * ; Q$ U% I5 S2 g9 Y [0 f8 g- J
- * @param hql
3 t; k- V3 J2 e- s - * @param param 4 k$ a% j8 {) F! v% H; k% ^
- * @param page
7 b1 ?, X4 L. M& A- e - * @param rows : [ R/ e. D4 i4 w9 N4 b' m
- * @return 2 M. R6 f# n4 E( Q& P
- */ ( W+ @$ J/ ~; _ Z8 v' }- V
- public List<T> find(String hql, List<Object> param, Integer page, Integer rows); * w% f, c0 ^# p ~
- ; z) M4 ^0 R! J$ f- V+ V2 ?% A
- /**
5 w- j# s1 n# f" k Q - * 获得一个对象
# n6 ` W5 L. c& n' @ - * 1 I: {2 P$ U6 Z, a
- * @param c . @5 ]9 c: L) F' [9 j, r' h
- * 对象类型
2 Q0 x, c% }# |; E - * @param id ( t: }. i" U3 F: W0 q" E. a
- * @return Object 9 \* Q: |6 z( }1 B2 k
- */
9 z+ |6 }+ r9 Q - public T get(Class<T> c, Serializable id);
5 L, p9 `7 A4 C& c1 q( @ - 9 C' M* l! m0 N2 G' p8 Q# f! g
- /** & x3 n/ J4 G2 Q. l9 I/ M9 T0 U! h
- * 获得一个对象
9 `& G3 t- e/ ]9 a - * 4 L, W! Q; }4 b) N
- * @param hql
0 ?4 W( l5 {) } - * @param param
% F4 Z2 F: T$ S - * @return Object 7 {& ~: Y9 Y/ k4 q6 {0 D# J
- */ * P/ g Y+ ?) j# d4 _0 B% U8 k/ n
- public T get(String hql, Object[] param); O+ V+ [' s0 {# ?1 Y8 ]
- * v' ^3 h) T' g) p3 P4 B: B
- /** : d' o: D0 M8 m3 M5 D7 }. l+ U
- * 获得一个对象
5 U% T# B2 E O - *
! `1 w9 K& i2 g& l - * @param hql 5 e1 a+ f4 B! [6 `
- * @param param
$ t. j, T! x1 d( L1 p4 |: | - * @return
, v+ l* K- v/ y - */
: I& q+ R0 t- D7 M4 F- L, q8 ^7 s7 ? - public T get(String hql, List<Object> param);
7 g `) k/ j1 q, V - 2 k1 p3 j$ k" a/ s
- /**
. p: K; G( M. ]0 k' T8 D - * select count(*) from 类
$ w& d, Y( p8 B" I3 X+ Q# j3 G - *
% @+ c) X ^# e L T: ` - * @param hql
) m9 k' `4 `9 Q# F - * @return
3 Q! K- d1 B4 \' I - */
, Q# e' W5 a/ X8 G8 d! }8 f - public Long count(String hql); 9 G6 X2 `* R0 r/ s6 i! M
- 3 K" A6 ^! [+ r9 ~4 x+ L
- /**
; P* i7 [& T4 T5 q ~ - * select count(*) from 类
+ s7 }* ]: k3 p* R5 Z& g - *
1 E" w( c7 G) _: H - * @param hql 3 `3 Q0 q1 y/ B; ?- I
- * @param param
9 |2 K* ^5 c; ^' R: B) F - * @return
* z i$ u* d6 B! `5 u - */ % W! j/ A4 a' B8 q; d
- public Long count(String hql, Object[] param);
" a" U- |* k. a -
2 @2 Q8 O% g+ Z* V8 n5 K - /** ; \# M; S( T7 F8 k
- * select count(*) from 类 4 a! V3 ^! W6 c
- *
. g/ a3 L2 L/ V' C - * @param hql
# D3 M& L5 {: i+ R, E( w9 F - * @param param
/ E6 w. |; \ U' _ - * @return
$ V4 k* ]+ K( t! \6 o0 W) _+ O - */ + l+ h" W! D' d; s/ {
- public Long count(String hql, List<Object> param);
1 Q. i0 R2 S: [ -
+ ?: w- v) M% Q" U5 I - /**
9 w& e5 M7 Z4 D; ^2 `; y - * 执行HQL语句 9 @% K8 P& K" S, s
- * 0 ~* Y! ~) d6 i1 V) V+ U( G
- * @param hql
" {8 Q, z) p' O& h0 F: v& h - * @return 响应数目 $ a* ]" A4 @. V! N
- */
+ @( u8 ~. _2 d1 v: R - public Integer executeHql(String hql);
4 S& w/ E$ t6 h3 Q -
' k0 @* `4 T4 r& x' B - /** 6 ?% j0 }' B0 u. I
- * 执行HQL语句 ' W; T2 H0 G& Y8 L
- * 5 S7 B" o# l( L4 e9 x/ ?0 p
- * @param hql 7 M" ]6 ~. y4 a$ @
- * @param param # `. W. \1 R: w+ d
- * @return 响应数目 # r1 q7 T9 J5 b
- */ 0 i" T; j J$ E
- public Integer executeHql(String hql, Object[] param); 3 ^/ _ X" ~, x% f* R9 e2 \- g4 p
- 1 N; z4 C' y* |9 u' @% V6 J
- /** 2 M7 H1 g0 _: W. r
- * 执行HQL语句
$ H) @+ q4 s0 Z# K4 i% W - *
0 t+ Z+ [1 X& T4 C I - * @param hql
: M! n+ B# l; h. B - * @param param - m, G1 y" h, ?1 x3 h
- * @return : v( T9 p! A% c, s" M' c, q& o
- */ 6 y/ D1 e& N: g$ }' Y1 O' q; h
- public Integer executeHql(String hql, List<Object> param); + s0 Q$ i4 U+ ~0 m' X# W2 W" K# m
-
* [% `! E- m4 ^; ~ - }
复制代码- package cn.itcast.dao;
3 d [ Y* u$ A' {( [) k/ w - H. w$ e* C7 N$ F7 D' T/ h
- import java.io.Serializable;
4 f+ U0 e; n o - import java.util.List; Y$ q# H7 ]1 T
- 1 D& M5 W3 p4 `5 d" e# z; r
- /**
$ A" l9 S/ r9 C+ q# x% s X. p - * BaseDao" D. z2 T" {) K o( d6 A6 z" C
- * @author Administrator* q) N) P- k. F+ p
- *
/ g" O1 p! x, I9 j% o - * @param <T>
8 a' S, x. n/ e- V1 z0 y3 i" c - */: K/ ^! O' ^: R1 \. |
- public interface BaseDao<T> {
" w$ I& b" c2 y5 _% ?( i - /**
# ]4 y% f: W- P, ]- X/ b P - * 保存一个对象
: m8 K+ `6 S/ w \* I1 F - * 2 C- S4 q% A' }0 \3 E! B
- * @param o ; r+ M: z! I: G. v1 l/ U* ^
- * @return
) A3 [ e( E& c1 G" t - */ $ a6 i0 r" h% j# g; Z
- public Serializable save(T o); 8 ~" V$ T1 |4 }- e
- % ?8 K4 x. P, d; n* a! l- m0 L
- /**
3 Z7 F1 L; T: ^" i& b. V$ n4 w - * 删除一个对象 $ }/ F C# q2 B P
- *
# \8 F3 x' x6 N( a7 o, e2 d2 A/ v - * @param o " s% d$ z! G- L# g1 c8 W
- */
! j4 d. ~4 F8 N0 B N - public void delete(T o); $ H9 U7 C" q( B8 f
-
$ h+ b8 C# l$ l' g: ?! m - /** ) R% u$ {( d* @0 K3 p
- * 更新一个对象 0 t% ^5 A4 g0 b& h3 {6 Y4 g
- *
7 R8 \4 A# X0 Q1 @ - * @param o
2 P1 r/ Q" O" N/ P8 |4 j - */
( t4 ^1 n) B1 v+ y - public void update(T o); 5 k0 ?1 t% P( I: R1 g
-
# K9 o' [- l' t4 [7 {! f- {6 D - /**
! _: n/ j! Q9 m- V9 N - * 保存或更新对象 + Q( [5 {1 U/ k0 i) d* l3 a5 w
- *
# f8 M+ }1 G& a( O; A5 Z - * @param o ( Y9 w: G0 s" h8 i2 \
- */
- C" u7 a2 V; G0 x' n" d - public void saveOrUpdate(T o);
3 F3 ^# ~1 u) ]/ c4 I0 r! O+ ? - & u' m+ `9 w) O5 }
- /** + D4 {3 u7 v8 K8 ]5 L ^& J
- * 查询 ' o; q! j6 j! n1 e* d
- *
" V+ _. _& o( j, v - * @param hql
, l- W1 A" k8 a& b/ ~% \7 w8 y - * @return , {+ x# Y8 c; t8 N+ c/ B. q
- */ ) R2 k& U1 j9 T$ D' _1 E' I6 i$ R
- public List<T> find(String hql); 3 k# S% n. B; b) {9 S3 G
-
) ^* J! a; Q9 C5 ? - /** # I. ^) Y$ Z' }+ f9 N
- * 查询集合
# V1 W- F3 q# L& V - * ; L- X8 w1 d. u* C; \
- * @param hql 8 S) m) Z* N. a6 t
- * @param param # E7 W- y1 L q$ J
- * @return
: W G* T: N/ r - */ : j% q2 v4 e7 |# V$ B
- public List<T> find(String hql, Object[] param); 4 g$ @# C/ h/ a: W4 ?2 {
-
6 N/ Y. E! m$ A0 C; |( D2 e; A' j - /**
2 i4 P- e& s4 V( O! e' Q/ v _3 E- Y( N q - * 查询集合
' g/ v- Z7 g0 s& B8 S4 _6 E, V- v - * 3 r2 H( ]+ E! h" a' S* k$ L
- * @param hql + Z* q6 i% t+ G" [
- * @param param
7 B6 Q: _3 W# y: a% i - * @return
4 ?' s/ a; y) I8 L& W' M% w2 q - */
8 R3 X3 F) a9 a0 r ` r" j - public List<T> find(String hql, List<Object> param); + t9 q4 {9 P8 o( M6 E" y" K
- ) r: u' |) C% N" b) x% |% b0 Y
- /**
( N5 M6 |" J% e - * 查询集合(带分页)
2 D8 T$ F9 }* j2 l/ u+ N* Y; d - *
7 |9 B% ^( x. b2 R# ]7 ? - * @param hql
) Y* r3 z( y- C: N- M5 D& H - * @param param 3 x! W9 d9 p+ e* r4 q
- * @param page 1 c( r; x0 r' |6 _: k4 ]
- * 查询第几页 2 N; {# f" D& m' e8 M/ {4 X
- * @param rows 8 \5 G' G. Q; h/ F
- * 每页显示几条记录 2 G. i) j2 r: ~2 I Y+ a8 \3 m
- * @return & Q d- a3 U8 S4 h" f- j% Y- P
- */ 4 S; F5 s6 Z; W7 r
- public List<T> find(String hql, Object[] param, Integer page, Integer rows); 2 w$ M4 L8 u& ^6 S
- " m3 ]* w1 y6 S9 s1 R4 ~
- /** 0 A! B1 O. V( A+ X) m8 n* F
- * 查询集合(带分页) " }) W9 d* f3 C( `: \
- * . k5 `; I, g; M1 } n( I E3 T
- * @param hql
d: [* r6 |3 d3 d5 u1 V. c - * @param param
q U Y$ ~) U Q M- w @( q - * @param page
1 _2 R S/ O+ t5 p" F5 @ - * @param rows 5 x5 k& P: X* @3 s: s
- * @return
* L' m' M2 K+ L: P: s0 R* B' Z! K% { - */ 0 q9 g; t$ t' i& I }' ?2 l: c
- public List<T> find(String hql, List<Object> param, Integer page, Integer rows); : P9 z% u+ @* M& z
-
6 [* V+ f) M/ A# J7 j - /**
0 c9 J+ J# w) P* r: X1 V' ]( \ - * 获得一个对象
5 n( ~3 s/ o8 ~ I! d/ b% N - *
: y- i1 m {, X$ K+ V V - * @param c
/ c' t( G4 Q1 q - * 对象类型 6 S) @( {5 ~" q; q4 a ^- w
- * @param id
0 Q0 g8 F' ]+ T0 a% \. V - * @return Object # I! _( v7 Z& t( x" F
- */
M: c' a" y* ~1 w9 s( h1 v - public T get(Class<T> c, Serializable id);
, A7 Y, W3 D) j7 O1 k. J - + j9 |# f9 h" U4 M: d' @% e
- /** ; C" Y0 w& a5 P' y
- * 获得一个对象 d6 M; Y6 G& y
- *
$ M5 `- B: a. j6 a5 y" J4 \5 W - * @param hql 1 C5 q7 j' t! o8 m8 S' j+ ~6 d! `! b
- * @param param ' N/ w& l4 D6 G+ X5 }* }' I8 b& }
- * @return Object
3 v0 K5 C/ g- U/ m' q - */ : l/ Z& z& `# G
- public T get(String hql, Object[] param);
- N$ [9 f/ S; }& O; q - # I b& q! ] a5 [' \
- /**
. V( M c H; l _ - * 获得一个对象 * i, X/ Z- l B* {6 t- Y
- * 8 u1 x8 [9 y" r% l2 L
- * @param hql
S* `( i1 B8 Q - * @param param
0 O3 e; r& u2 X# } - * @return & ?; G: L2 m3 k1 \" w- \5 o( D
- */ 3 v+ g9 N- _! q& W
- public T get(String hql, List<Object> param);
4 S5 q5 w/ G8 @; i! A" Z& l2 i) { - : s. f7 L0 T; G. f. y+ E
- /**
; X ?$ n# b1 U - * select count(*) from 类
0 f4 _& z$ M( ^* `. [ - *
" i' \: e+ u2 E8 E7 } - * @param hql ' @, N: t) k, E* Y( n# c% a
- * @return
+ Y8 U% V P+ I& w" R3 d/ q - */
$ r5 ^2 y. X: y% d# J$ |. e - public Long count(String hql); ) T' K4 W& X, l" \
- * G+ ^- b& T: H% ]
- /**
" g- @8 h- Y$ N* { j1 y% S - * select count(*) from 类
) ^) Q/ ]: g8 D6 n - *
5 j6 N! z* \% ]$ h7 J/ x - * @param hql # v" T( @- w k2 y# V! \
- * @param param
; K( `4 k& o% U2 e0 I8 N- h! j - * @return + D9 S6 _4 t2 n# L2 b2 R/ ^
- */ 8 y C, `; N$ u; R4 T1 E- n. d
- public Long count(String hql, Object[] param);
2 ^" }+ o9 {4 j1 V7 _9 } - 8 h: }/ ~ { [
- /** ) n$ Y0 m: b3 {1 S* p, R
- * select count(*) from 类
, a' |6 i+ [* E; f" k! c - * ! P7 r8 h; _$ K0 P
- * @param hql 5 |& h9 {3 e% ~& f# W6 h
- * @param param
% T3 x$ @/ m a% | - * @return * u4 J! e- l0 d, F5 ]0 e
- */
: ]6 U! O8 _! _$ x8 N - public Long count(String hql, List<Object> param);
7 \5 L8 n2 ? J$ R' _ -
" r7 X) g' {: Z9 k0 A - /** 5 ]8 n8 t: {% \2 Q1 b4 z4 r9 V
- * 执行HQL语句 & m+ M! S) n3 Q# e3 m' z
- *
" _# @) d; ^: T2 D. ]; x$ { - * @param hql , t! a% P/ c+ d' F+ |# H- O
- * @return 响应数目 3 `" l# e4 n( R: i( t6 Z
- */
X, ]( k2 R5 A" u - public Integer executeHql(String hql); 3 U I5 d% N8 d3 W4 x
- 0 [3 [! q. ~2 ~- o" p' c* a
- /**
' O* ]& z; n- n y1 ^ - * 执行HQL语句
1 R8 }3 V- z: _0 x - * / Z: x& g: V# v, K
- * @param hql 4 Q& o2 ?* v; e' [2 L0 O
- * @param param
: p$ Q4 ^7 g% x - * @return 响应数目
4 ~: s4 d/ U/ z2 `3 O. ` - */
3 Z$ Z! J$ g5 `( ^ - public Integer executeHql(String hql, Object[] param); $ Z% E# K9 N/ i7 b3 Z4 e
- ! [1 c# k- m8 s& S @
- /** + x( r# y2 f+ D! Z& e# Q
- * 执行HQL语句
- D" Y5 P( K* i ?" R - * 3 m; {+ a8 R& z0 y# S; y
- * @param hql
5 t: ]5 {7 X, K - * @param param 5 s; _3 N( i+ Y6 a
- * @return ( I7 w% W5 }' p. L) b& `* u
- */
6 j# x6 i8 J2 z3 I - public Integer executeHql(String hql, List<Object> param);
% U4 c: k6 B2 c. Q& y7 l - . s* r1 U# G, j" ]
- }
复制代码- package cn.itcast.dao;7 A- T) A' c p S$ v- \' ~; x
* c6 P( `5 i' i& L6 [, E- import cn.itcast.entity.TEmail;
; w3 R1 f5 F0 d& {& w - 6 I) i" v2 X0 b% M$ V* @
- /**
. a# w* h6 G/ C5 } - * EmailDao
3 |! b5 ]7 F0 U% @ - * @author Administrator
+ a- j. j. j9 _* X# F' |2 |2 W - *
. O& ^! }" x, p - */- U2 N0 ~* j. [9 e0 S
" S- S6 x9 u5 G+ h, S( f- public interface TEmailDao {0 D/ y1 l9 a4 c" I
- public TEmail Login(String LoginName,String Password);
9 K* l) [+ h/ D5 O, F# u - % Z$ h. G; a0 h( h& D; m
- public TEmail FindByEmail(String param);* ]8 [" S7 y7 [$ q6 O0 d# ^4 T4 s: ]" X
- ! \0 M2 f8 y- Y8 n7 c. ^! ?
- public Integer count(String param);
+ N5 G: [5 N2 v -
5 A/ j% ]3 j' Q+ Q3 k% V - public void saveOrUpdate(TEmail T);/ r. T, M7 M3 H% m- h+ F5 {( k' ^
- + t0 ]( Z- Y# V4 {
- public void save(TEmail T);% B$ H0 N E d. w0 [
-
- V; R" q+ M+ s- H. a1 ^5 h9 {6 X - public void update(TEmail T);4 w$ d0 v/ t* x2 z6 ^
- 9 F5 K' }/ Z3 {- y" q$ }
- public TEmail get(Integer id);
4 z$ N! d- o! F* U2 ~7 j - }
复制代码- package cn.itcast.daoImpl;
( V J3 Y A7 Q9 e+ R
" I+ ]$ K0 c2 j* i1 }+ u" e, O1 e! z. `$ g- import cn.itcast.dao.BaseDao;
& @/ N' k t, F& z1 w- @1 f/ y - import cn.itcast.dao.TEmailDao;. I, _+ {( z) F$ u8 m; O8 a* y
- import cn.itcast.entity.TEmail;2 Y# n1 P8 M$ ~8 Y) q
- : s9 C) {' a3 b! y
- /**3 x" n; `$ G$ P: }
- * EmailDao实现类调用BaseDao实现EmailDao中的方法
5 V6 V V* F" R$ Z" a# m: d3 k - * @author Administrator
8 l c' g2 }/ S3 d2 d0 ~6 m - */ M, O5 ~: r: @- b* z0 Y
- */! `0 L8 m$ o2 D7 F% l; N5 a T
- public class TEmailDaoImpl implements TEmailDao {
9 J. c" X2 x: R) g2 T - private BaseDao<TEmail> baseDao;
s* \ K& x- Z5 f/ T0 Y* X -
/ k$ f1 c7 \% C2 o) B - public BaseDao<TEmail> getBaseDao() {
+ t a5 G$ [. A# O0 T+ I, V - return baseDao;$ t0 A' H0 s. o# q% Z+ |1 R2 }
- }* t" C( E& o' o
% O% ^. n; s8 L& x- N* x8 G- public void setBaseDao(BaseDao<TEmail> baseDao) {$ q' R! o$ X! T2 U' e, C
- this.baseDao = baseDao;
1 m1 ]7 |- Z: K: I/ u - }
8 j. n# R w$ r+ y$ h - / `/ r; v5 d& {" {5 M
- public TEmail Login(String LoginName,String Password) {5 T# I3 l+ K+ j( d5 g
- String hql="From TEmail where loginName=? and password=?";: o# a7 T; j" }) H) I
- return baseDao.get(hql, new Object[]{LoginName,Password});
( \5 t$ P! I; W& F. u' g( F - }
0 f- F& c- O% c; J
* ^9 M. Z8 C% c- public TEmail FindByEmail(String param) {* O: i4 m- }7 [9 R b
- String hql="From TEmail where email=?";
. \& }5 c& f D! i0 e. { - return baseDao.get(hql, new Object[]{param});% u8 K$ V; a5 u: x
- }
# s ^* s2 [& g7 |8 g
3 s1 B, S7 K( Q( Z( V5 e- public Integer count(String param) { F% R6 n: K0 Z# C8 ^6 V
- String hql="Select count(*) From TEmail where email=?";4 N0 w2 Z; @/ A7 i( r' Q# l& |
- Long s=baseDao.count(hql, new Object[]{param});
T+ B3 g2 k7 q4 L - return s.intValue();
: `7 ?. S+ n/ a3 z+ g3 v- ^: O* } - }
: g) I- t2 ^) P* S# Q' e+ E' f) J6 w -
, ]& K |, `4 W5 ]% c - public void saveOrUpdate(TEmail T){. m$ p/ h3 P; p1 D) J, r0 v% h; u( o( K9 p
- baseDao.saveOrUpdate(T);- D2 p @' q/ D/ X9 e
- }
" [ @: j# q8 h; k( ]. O! x& v -
5 j, G, L& x# x0 z# U2 Z- w+ L - public void save(TEmail T){/ s+ q# v9 @8 G" n) ^+ d
- baseDao.save(T);- Z" i+ \" }- D9 C8 h
- }' Z/ W" A& D/ Y0 W
-
8 C$ D& J0 J' z" V9 c# q, U - public void update(TEmail T){
8 u' h+ ]6 z Z6 M - baseDao.update(T);
2 g5 {: z/ B4 }: h# b z, y - }
2 f( D7 i2 r- g7 K, M
2 r) J+ l$ Q( h: k/ X- public TEmail get(Integer id) {
% V! ]0 d8 j% ?$ U- R" V' Q# F - return baseDao.get(TEmail.class, id);0 m+ s |$ Y+ u' P5 P
- }
( {# H0 g) o+ ^$ ~" ]5 U4 H! T - $ P, w8 G, q5 K; u# ^
- 8 w7 |- B0 H3 R5 J1 l+ Q2 T! A4 a q
- }
复制代码
) i5 g: W) y. l' O
$ ]6 @, i) @/ X3 G/ h# o
0 o+ f9 D) T$ R/ V |
|