1 2 23 package com.geinuke.dao; 24 25 import java.sql.SQLException ; 26 import java.util.ArrayList ; 27 import java.util.List ; 28 29 import com.geinuke.common.UserI; 30 import com.geinuke.vo.BlockDBVO; 31 32 33 public class BlockDAO extends GeiDAO{ 34 35 36 public BlockDAO() throws Exception { 37 super(); 38 39 } 40 45 public ArrayList getAllBlocks()throws SQLException { 46 ArrayList list=null; 47 List llist=null; 48 try{ 49 sqlMap().startTransaction(); 50 llist=sqlMap().queryForList("getAllBlocks",""); 51 sqlMap().commitTransaction(); 52 }finally{ 53 sqlMap().endTransaction(); 54 } 55 list=new ArrayList (llist); 56 return list; 57 } 58 59 public ArrayList getAllStoredBlocks()throws SQLException { 60 ArrayList list=null; 61 List llist=null; 62 try{ 63 sqlMap().startTransaction(); 64 llist=sqlMap().queryForList("getAllStoredBlocks",""); 65 sqlMap().commitTransaction(); 66 }finally{ 67 sqlMap().endTransaction(); 68 } 69 list=new ArrayList (llist); 70 return list; 71 } 72 73 public void updateDBBlock(BlockDBVO blo)throws Exception { 74 try{ 75 this.sqlMap().startTransaction(); 76 this.sqlMap().update("updateDBBlock",blo); 77 sqlMap().commitTransaction(); 78 }finally{ 79 this.sqlMap().endTransaction(); 80 } 81 82 } 83 84 public void delDBBlock(int id)throws Exception { 85 try{ 86 this.sqlMap().startTransaction(); 87 this.sqlMap().delete("delDBBlock",new Integer (id)); 88 sqlMap().commitTransaction(); 89 }finally{ 90 this.sqlMap().endTransaction(); 91 } 92 93 } 94 95 public void insertDBStoredBlock(BlockDBVO blo)throws Exception { 96 try{ 97 this.sqlMap().startTransaction(); 98 this.sqlMap().insert("insertDBStoredBlock",blo); 99 sqlMap().commitTransaction(); 100 }finally{ 101 this.sqlMap().endTransaction(); 102 } 103 104 } 105 106 public BlockDBVO getBlockById(int id)throws SQLException { 107 BlockDBVO res=null; 108 109 try{ 110 sqlMap().startTransaction(); 111 res=(BlockDBVO)sqlMap().queryForObject("getBlockById",new Integer (id)); 112 sqlMap().commitTransaction(); 113 }finally{ 114 sqlMap().endTransaction(); 115 } 116 117 return res; 118 } 119 120 public BlockDBVO getBlockByName(String name)throws SQLException { 121 BlockDBVO res=null; 122 123 try{ 124 sqlMap().startTransaction(); 125 res=(BlockDBVO)sqlMap().queryForObject("getBlockByName",name); 126 sqlMap().commitTransaction(); 127 }finally{ 128 sqlMap().endTransaction(); 129 } 130 131 return res; 132 } 133 134 public ArrayList getBlocksForUser(UserI user)throws SQLException { 135 ArrayList list=null; 136 List llist=null; 137 try{ 138 sqlMap().startTransaction(); 139 llist=sqlMap().queryForList("getBlocksForUser",user); 140 sqlMap().commitTransaction(); 141 }finally{ 142 sqlMap().endTransaction(); 143 } 144 list=new ArrayList (llist); 145 return list; 146 } 147 148 } 149 | Popular Tags |