KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > geinuke > dao > SessionDAO


1
2  /*
3  -- GeiNuke --
4 Copyright (c) 2005 by Roberto Sidoti [geinuke@users.sourceforge.net]
5  http://www.hostingjava.it/-geinuke/
6
7 This file is part of GeiNuke.
8
9     GeiNuke is free software; you can redistribute it and/or modify
10     it under the terms of the GNU General Public License as published by
11     the Free Software Foundation; either version 2 of the License, or
12     (at your option) any later version.
13
14     GeiNuke is distributed in the hope that it will be useful,
15     but WITHOUT ANY WARRANTY; without even the implied warranty of
16     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17     GNU General Public License for more details.
18
19     You should have received a copy of the GNU General Public License
20     along with GeiNuke; if not, write to the Free Software
21     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */

23 package com.geinuke.dao;
24
25 import java.util.ArrayList JavaDoc;
26 import java.util.List JavaDoc;
27
28 import com.geinuke.vo.SessionVO;
29
30 public class SessionDAO extends GeiDAO{
31
32     
33     public SessionDAO() throws Exception JavaDoc {
34         super();
35         
36     }
37     
38     public void insertSession(SessionVO s) throws Exception JavaDoc{
39         
40         try{
41             this.sqlMap().startTransaction();
42             this.sqlMap().insert("insSession",s);
43             this.sqlMap().commitTransaction();
44         }finally{
45             this.sqlMap().endTransaction();
46         }
47         
48     }
49     
50     public void deleteExpiredSessions(long deadline) throws Exception JavaDoc{
51         
52         try{
53             this.sqlMap().startTransaction();
54             this.sqlMap().delete("deleteExpiredSessions",new Long JavaDoc(deadline));
55             this.sqlMap().commitTransaction();
56         }finally{
57             this.sqlMap().endTransaction();
58         }
59         
60     }
61     
62     public void deleteSession(SessionVO s) throws Exception JavaDoc{
63         
64         try{
65             this.sqlMap().startTransaction();
66             this.sqlMap().delete("deleteSession",s);
67             this.sqlMap().commitTransaction();
68         }finally{
69             this.sqlMap().endTransaction();
70         }
71         
72     }
73     
74     
75     public SessionVO getSessionByID(SessionVO s) throws Exception JavaDoc{
76         SessionVO ses=null;
77         try{
78             this.sqlMap().startTransaction();
79             ses=(SessionVO)this.sqlMap().queryForObject("getSessionByID",s);
80             this.sqlMap().commitTransaction();
81         }finally{
82             this.sqlMap().endTransaction();
83         }
84         return ses;
85     }
86     
87     public ArrayList JavaDoc getSessionsByIdRole(int idr) throws Exception JavaDoc{
88         ArrayList JavaDoc list=null;
89         List JavaDoc llist=null;
90         try{
91             this.sqlMap().startTransaction();
92             llist=(List JavaDoc)this.sqlMap().queryForList("getSessionsByIdR",new Integer JavaDoc(idr));
93             this.sqlMap().commitTransaction();
94         }finally{
95             this.sqlMap().endTransaction();
96         }
97         list=new ArrayList JavaDoc(llist);
98         return list;
99     }
100     
101     public ArrayList JavaDoc getSessions() throws Exception JavaDoc{
102         
103         ArrayList JavaDoc list=null;
104         List JavaDoc aux=null;
105         try{
106             this.sqlMap().startTransaction();
107             aux=(List JavaDoc)this.sqlMap().queryForList("getSessions","");
108             this.sqlMap().commitTransaction();
109             
110         }finally{
111             this.sqlMap().endTransaction();
112         }
113         list=new ArrayList JavaDoc(aux);
114         return list;
115     }
116     
117     
118     public ArrayList JavaDoc getLastSessions(int rId) throws Exception JavaDoc{
119         
120         ArrayList JavaDoc list=null;
121         List JavaDoc aux=null;
122         try{
123             this.sqlMap().startTransaction();
124             aux=(List JavaDoc)this.sqlMap().queryForList("getLastSessions",new Integer JavaDoc(rId));
125             this.sqlMap().commitTransaction();
126             
127         }finally{
128             this.sqlMap().endTransaction();
129         }
130         list=new ArrayList JavaDoc(aux);
131         return list;
132     }
133 }
134
Popular Tags