KickJava   Java API By Example, From Geeks To Geeks.

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


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.BlogPostVO;
29
30
31
32 public class BlogDAO extends GeiDAO{
33
34     
35     public BlogDAO() throws Exception JavaDoc {
36         super();
37         
38     }
39     
40     public void insertBlogPost(BlogPostVO u) throws Exception JavaDoc{
41         
42         try{
43             this.sqlMap().startTransaction();
44             this.sqlMap().insert("insBlogPost",u);
45             this.sqlMap().commitTransaction();
46         }finally{
47             this.sqlMap().endTransaction();
48         }
49         
50     }
51     
52     public void deleteBlogPostByBID(int bid) throws Exception JavaDoc{
53         
54         try{
55             this.sqlMap().startTransaction();
56             this.sqlMap().delete("delBlogPost",new Integer JavaDoc(bid));
57             this.sqlMap().commitTransaction();
58         }finally{
59             this.sqlMap().endTransaction();
60         }
61         
62     }
63     
64     public BlogPostVO getBlogPostByBID(int bid) throws Exception JavaDoc{
65         BlogPostVO user=null;
66         try{
67             this.sqlMap().startTransaction();
68             user=(BlogPostVO)this.sqlMap().queryForObject("getBlogPostByBID",new Integer JavaDoc(bid));
69             this.sqlMap().commitTransaction();
70         }finally{
71             this.sqlMap().endTransaction();
72         }
73         return user;
74     }
75     
76     public BlogPostVO getLastBlogPostByUID(int uid) throws Exception JavaDoc{
77         BlogPostVO user=null;
78         try{
79             this.sqlMap().startTransaction();
80             user=(BlogPostVO)this.sqlMap().queryForObject("getLastBlogPostByUID",new Integer JavaDoc(uid));
81             this.sqlMap().commitTransaction();
82         }finally{
83             this.sqlMap().endTransaction();
84         }
85         return user;
86     }
87     
88     public ArrayList JavaDoc getBlogPostsByUID(int uid)throws Exception JavaDoc{
89         ArrayList JavaDoc list=null;
90         List JavaDoc llist=null;
91         try{
92             sqlMap().startTransaction();
93             llist=sqlMap().queryForList("getBlogPostsByUID",new Integer JavaDoc(uid));
94             this.sqlMap().commitTransaction();
95         }finally{
96             sqlMap().endTransaction();
97         }
98         list=new ArrayList JavaDoc(llist);
99         
100         return list;
101     }
102     
103     public ArrayList JavaDoc getBlogPostsByTitle(String JavaDoc words)throws Exception JavaDoc{
104         ArrayList JavaDoc list=null;
105         List JavaDoc llist=null;
106         words="%"+words+"%";
107         try{
108             sqlMap().startTransaction();
109             llist=sqlMap().queryForList("getBlogPostsByTitle",words);
110             this.sqlMap().commitTransaction();
111         }finally{
112             sqlMap().endTransaction();
113         }
114         list=new ArrayList JavaDoc(llist);
115         
116         return list;
117     }
118     
119     public ArrayList JavaDoc getBlogPostsByText(String JavaDoc words)throws Exception JavaDoc{
120         ArrayList JavaDoc list=null;
121         List JavaDoc llist=null;
122         words="%"+words+"%";
123         try{
124             sqlMap().startTransaction();
125             llist=sqlMap().queryForList("getBlogPostsByText",words);
126             
127             this.sqlMap().commitTransaction();
128         }finally{
129             sqlMap().endTransaction();
130         }
131         list=new ArrayList JavaDoc(llist);
132         
133         return list;
134     }
135     
136     public ArrayList JavaDoc getBlogPostsByTitleOrText(String JavaDoc words)throws Exception JavaDoc{
137         ArrayList JavaDoc list=null;
138         List JavaDoc llist=null;
139         words="%"+words+"%";
140         try{
141             sqlMap().startTransaction();
142             llist=sqlMap().queryForList("getBlogPostsByTitleOrText",words);
143             
144             this.sqlMap().commitTransaction();
145         }finally{
146             sqlMap().endTransaction();
147         }
148         list=new ArrayList JavaDoc(llist);
149         
150         return list;
151     }
152     
153 }
154
Popular Tags