| 1 2 23 package com.geinuke.dao; 24 import java.sql.SQLException ; 25 import java.util.ArrayList ; 26 import java.util.List ; 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 { 37 super(); 38 39 } 40 41 public CategoryVO getCategoryByIdAndCatType(CategoryVO c) throws Exception { 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 { 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 getCategoriesByFId(int fid)throws Exception { 66 ArrayList list=null; 67 List llist=null; 68 try{ 69 sqlMap().startTransaction(); 70 llist=sqlMap().queryForList("getCategoriesByFId",new Integer (fid)); 71 this.sqlMap().commitTransaction(); 72 }finally{ 73 sqlMap().endTransaction(); 74 } 75 list=new ArrayList (llist); 76 77 return list; 78 } 79 80 public void insertCategory(CategoryVO c) throws Exception { 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 getCategoriesByCatType(String type)throws SQLException { 93 ArrayList list=null; 94 List llist=null; 95 96 try{ 97 sqlMap().startTransaction(); 98 llist=sqlMap().queryForList("getCategoriesByCatType",type); 99 this.sqlMap().commitTransaction(); 100 list=new ArrayList (llist); 101 }finally{ 102 sqlMap().endTransaction(); 103 } 104 105 106 return list; 107 } 108 109 public ArrayList getAllCategories()throws SQLException { 110 ArrayList list=null; 111 List llist=null; 112 113 try{ 114 sqlMap().startTransaction(); 115 llist=sqlMap().queryForList("getAllCategories",""); 116 this.sqlMap().commitTransaction(); 117 list=new ArrayList (llist); 118 }finally{ 119 sqlMap().endTransaction(); 120 } 121 122 123 return list; 124 } 125 126 127 public ArrayList getCategoriesByNews(NewsVO n)throws SQLException { 128 ArrayList list=null; 129 List llist=null; 130 131 try{ 132 sqlMap().startTransaction(); 133 llist=sqlMap().queryForList("getCategoriesByNews",n); 134 this.sqlMap().commitTransaction(); 135 list=new ArrayList (llist); 136 }finally{ 137 sqlMap().endTransaction(); 138 } 139 140 141 return list; 142 } 143 144 145 146 } 147 | Popular Tags |