KickJava   Java API By Example, From Geeks To Geeks.

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


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 import java.sql.SQLException JavaDoc;
25 import java.util.ArrayList JavaDoc;
26 import java.util.List JavaDoc;
27
28 import com.geinuke.vo.CategoryVO;
29 import com.geinuke.vo.NewsVO;
30
31
32
33 public class CategoryDAO extends GeiDAO{
34
35     
36     public CategoryDAO() throws Exception JavaDoc {
37         super();
38         
39     }
40     
41     public CategoryVO getCategoryByIdAndCatType(CategoryVO c) throws Exception JavaDoc{
42         CategoryVO cc=null;
43         try{
44             this.sqlMap().startTransaction();
45             cc=(CategoryVO)this.sqlMap().queryForObject("getCategoryByIdAndCatType",c);
46             this.sqlMap().commitTransaction();
47         }finally{
48             this.sqlMap().endTransaction();
49         }
50         return cc;
51     }
52     
53     public CategoryVO getCategoryByTitleAndCatType(CategoryVO c) throws Exception JavaDoc{
54         CategoryVO cc=null;
55         try{
56             this.sqlMap().startTransaction();
57             cc=(CategoryVO)this.sqlMap().queryForObject("getCategoryByTitleAndCatType",c);
58             this.sqlMap().commitTransaction();
59         }finally{
60             this.sqlMap().endTransaction();
61         }
62         return cc;
63     }
64     
65     public ArrayList JavaDoc getCategoriesByFId(int fid)throws Exception JavaDoc{
66         ArrayList JavaDoc list=null;
67         List JavaDoc llist=null;
68         try{
69             sqlMap().startTransaction();
70             llist=sqlMap().queryForList("getCategoriesByFId",new Integer JavaDoc(fid));
71             this.sqlMap().commitTransaction();
72         }finally{
73             sqlMap().endTransaction();
74         }
75         list=new ArrayList JavaDoc(llist);
76         
77         return list;
78     }
79     
80     public void insertCategory(CategoryVO c) throws Exception JavaDoc{
81         
82         try{
83             this.sqlMap().startTransaction();
84             this.sqlMap().insert("insCategory",c);
85             this.sqlMap().commitTransaction();
86         }finally{
87             this.sqlMap().endTransaction();
88         }
89                 
90     }
91     
92     public ArrayList JavaDoc getCategoriesByCatType(String JavaDoc type)throws SQLException JavaDoc{
93         ArrayList JavaDoc list=null;
94         List JavaDoc llist=null;
95         
96         try{
97             sqlMap().startTransaction();
98             llist=sqlMap().queryForList("getCategoriesByCatType",type);
99             this.sqlMap().commitTransaction();
100             list=new ArrayList JavaDoc(llist);
101         }finally{
102             sqlMap().endTransaction();
103         }
104         
105         
106         return list;
107     }
108     
109     public ArrayList JavaDoc getAllCategories()throws SQLException JavaDoc{
110         ArrayList JavaDoc list=null;
111         List JavaDoc llist=null;
112         
113         try{
114             sqlMap().startTransaction();
115             llist=sqlMap().queryForList("getAllCategories","");
116             this.sqlMap().commitTransaction();
117             list=new ArrayList JavaDoc(llist);
118         }finally{
119             sqlMap().endTransaction();
120         }
121         
122         
123         return list;
124     }
125
126     
127     public ArrayList JavaDoc getCategoriesByNews(NewsVO n)throws SQLException JavaDoc{
128         ArrayList JavaDoc list=null;
129         List JavaDoc llist=null;
130         
131         try{
132             sqlMap().startTransaction();
133             llist=sqlMap().queryForList("getCategoriesByNews",n);
134             this.sqlMap().commitTransaction();
135             list=new ArrayList JavaDoc(llist);
136         }finally{
137             sqlMap().endTransaction();
138         }
139         
140         
141         return list;
142     }
143     
144     
145
146 }
147
Popular Tags