1 2 23 package com.geinuke.dao; 24 25 import java.util.ArrayList ; 26 import java.util.List ; 27 28 import com.geinuke.vo.BlogPostVO; 29 30 31 32 public class BlogDAO extends GeiDAO{ 33 34 35 public BlogDAO() throws Exception { 36 super(); 37 38 } 39 40 public void insertBlogPost(BlogPostVO u) throws Exception { 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 { 53 54 try{ 55 this.sqlMap().startTransaction(); 56 this.sqlMap().delete("delBlogPost",new Integer (bid)); 57 this.sqlMap().commitTransaction(); 58 }finally{ 59 this.sqlMap().endTransaction(); 60 } 61 62 } 63 64 public BlogPostVO getBlogPostByBID(int bid) throws Exception { 65 BlogPostVO user=null; 66 try{ 67 this.sqlMap().startTransaction(); 68 user=(BlogPostVO)this.sqlMap().queryForObject("getBlogPostByBID",new Integer (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 { 77 BlogPostVO user=null; 78 try{ 79 this.sqlMap().startTransaction(); 80 user=(BlogPostVO)this.sqlMap().queryForObject("getLastBlogPostByUID",new Integer (uid)); 81 this.sqlMap().commitTransaction(); 82 }finally{ 83 this.sqlMap().endTransaction(); 84 } 85 return user; 86 } 87 88 public ArrayList getBlogPostsByUID(int uid)throws Exception { 89 ArrayList list=null; 90 List llist=null; 91 try{ 92 sqlMap().startTransaction(); 93 llist=sqlMap().queryForList("getBlogPostsByUID",new Integer (uid)); 94 this.sqlMap().commitTransaction(); 95 }finally{ 96 sqlMap().endTransaction(); 97 } 98 list=new ArrayList (llist); 99 100 return list; 101 } 102 103 public ArrayList getBlogPostsByTitle(String words)throws Exception { 104 ArrayList list=null; 105 List 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 (llist); 115 116 return list; 117 } 118 119 public ArrayList getBlogPostsByText(String words)throws Exception { 120 ArrayList list=null; 121 List 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 (llist); 132 133 return list; 134 } 135 136 public ArrayList getBlogPostsByTitleOrText(String words)throws Exception { 137 ArrayList list=null; 138 List 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 (llist); 149 150 return list; 151 } 152 153 } 154 | Popular Tags |