KickJava   Java API By Example, From Geeks To Geeks.

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


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

24 package com.geinuke.dao;
25
26 import java.util.ArrayList JavaDoc;
27 import java.util.List JavaDoc;
28
29 import com.geinuke.vo.CommentVO;
30
31
32
33 public class CommentDAO extends GeiDAO{
34
35     
36     public CommentDAO() throws Exception JavaDoc {
37         super();
38         
39     }
40     
41     public void insertComment(CommentVO c) throws Exception JavaDoc{
42         
43         try{
44             this.sqlMap().startTransaction();
45             this.sqlMap().insert("insComment",c);
46             this.sqlMap().commitTransaction();
47         }finally{
48             this.sqlMap().endTransaction();
49         }
50         
51     }
52     
53     public void delCommentByCId(int cid) throws Exception JavaDoc{
54         
55         try{
56             this.sqlMap().startTransaction();
57             this.sqlMap().delete("delCommentByCId",new Integer JavaDoc(cid));
58             this.sqlMap().commitTransaction();
59         }finally{
60             this.sqlMap().endTransaction();
61         }
62         
63     }
64     
65     public void delForumCommentsByXId(int xid) throws Exception JavaDoc{
66         
67         try{
68             this.sqlMap().startTransaction();
69             this.sqlMap().delete("delForumCommentsByXId",new Integer JavaDoc(xid));
70             this.sqlMap().commitTransaction();
71         }finally{
72             this.sqlMap().endTransaction();
73         }
74         
75     }
76     
77     public void delForumCommentsByFId(int fid) throws Exception JavaDoc{
78         
79         try{
80             this.sqlMap().startTransaction();
81             this.sqlMap().delete("delForumCommentsByFId",new Integer JavaDoc(fid));
82             this.sqlMap().commitTransaction();
83         }finally{
84             this.sqlMap().endTransaction();
85         }
86         
87     }
88     
89     
90     public ArrayList JavaDoc getNewsCommentsByXId(int xid) throws Exception JavaDoc{
91         ArrayList JavaDoc list=null;
92         List JavaDoc llist=null;
93         try{
94             this.sqlMap().startTransaction();
95             llist=this.sqlMap().queryForList("getNewsCommentsByXId",new Integer JavaDoc(xid));
96             this.sqlMap().commitTransaction();
97         }finally{
98             this.sqlMap().endTransaction();
99         }
100         list=new ArrayList JavaDoc(llist);
101         return list;
102     }
103     
104     public ArrayList JavaDoc getForumCommentsByXId(int xid) throws Exception JavaDoc{
105         ArrayList JavaDoc list=null;
106         List JavaDoc llist=null;
107         try{
108             this.sqlMap().startTransaction();
109             llist=this.sqlMap().queryForList("getForumCommentsByXId",new Integer JavaDoc(xid));
110             this.sqlMap().commitTransaction();
111         }finally{
112             this.sqlMap().endTransaction();
113         }
114         list=new ArrayList JavaDoc(llist);
115         return list;
116     }
117     
118     public ArrayList JavaDoc getBlogCommentsByXId(int xid) throws Exception JavaDoc{
119         ArrayList JavaDoc list=null;
120         List JavaDoc llist=null;
121         try{
122             this.sqlMap().startTransaction();
123             llist=this.sqlMap().queryForList("getBlogCommentsByXId",new Integer JavaDoc(xid));
124             this.sqlMap().commitTransaction();
125         }finally{
126             this.sqlMap().endTransaction();
127         }
128         list=new ArrayList JavaDoc(llist);
129         return list;
130     }
131     
132     public int getForumCommentsCountByXId(int xid) throws Exception JavaDoc{
133         Integer JavaDoc i=null;
134         
135         try{
136             this.sqlMap().startTransaction();
137             i=(Integer JavaDoc)this.sqlMap().queryForObject("getForumCommentsCountByXId",new Integer JavaDoc(xid));
138             this.sqlMap().commitTransaction();
139         }finally{
140             this.sqlMap().endTransaction();
141         }
142         
143         return i.intValue();
144     }
145     
146     public int getBlogCommentsCountByXId(int xid) throws Exception JavaDoc{
147         Integer JavaDoc i=null;
148         
149         try{
150             this.sqlMap().startTransaction();
151             i=(Integer JavaDoc)this.sqlMap().queryForObject("getBlogCommentsCountByXId",new Integer JavaDoc(xid));
152             this.sqlMap().commitTransaction();
153         }finally{
154             this.sqlMap().endTransaction();
155         }
156         
157         return i.intValue();
158     }
159     
160     public CommentVO getLastForumCommentByFId(int fid) throws Exception JavaDoc{
161         CommentVO c=null;
162         
163         try{
164             this.sqlMap().startTransaction();
165             c=(CommentVO)this.sqlMap().queryForObject("getLastForumCommentByFId",new Integer JavaDoc(fid));
166             this.sqlMap().commitTransaction();
167         }finally{
168             this.sqlMap().endTransaction();
169         }
170         
171         return c;
172     }
173     
174     public CommentVO getLastForumCommentByTId(int tid) throws Exception JavaDoc{
175         CommentVO c=null;
176         
177         try{
178             this.sqlMap().startTransaction();
179             c=(CommentVO)this.sqlMap().queryForObject("getLastForumCommentByTId",new Integer JavaDoc(tid));
180             this.sqlMap().commitTransaction();
181         }finally{
182             this.sqlMap().endTransaction();
183         }
184         
185         return c;
186     }
187     
188     public CommentVO getNewsCommentByCId(int cid) throws Exception JavaDoc{
189         CommentVO res=null;
190         try{
191             this.sqlMap().startTransaction();
192             res=(CommentVO)this.sqlMap().queryForObject("getNewsCommentByCId",new Integer JavaDoc(cid));
193             this.sqlMap().commitTransaction();
194         }finally{
195             this.sqlMap().endTransaction();
196         }
197         return res;
198     }
199     
200     public CommentVO getForumCommentByCId(int cid) throws Exception JavaDoc{
201         CommentVO res=null;
202         try{
203             this.sqlMap().startTransaction();
204             res=(CommentVO)this.sqlMap().queryForObject("getForumCommentByCId",new Integer JavaDoc(cid));
205             this.sqlMap().commitTransaction();
206         }finally{
207             this.sqlMap().endTransaction();
208         }
209         return res;
210     }
211     
212     public CommentVO getBlogCommentByCId(int cid) throws Exception JavaDoc{
213         CommentVO res=null;
214         try{
215             this.sqlMap().startTransaction();
216             res=(CommentVO)this.sqlMap().queryForObject("getBlogCommentByCId",new Integer JavaDoc(cid));
217             this.sqlMap().commitTransaction();
218         }finally{
219             this.sqlMap().endTransaction();
220         }
221         return res;
222     }
223     
224     
225 }
226
Popular Tags