src/java/de/uapcore/lightpit/entities/ModuleDao.java

changeset 26
65d5a0ca49ae
parent 24
8137ec335416
child 27
1f2a96efa69f
equal deleted inserted replaced
25:559da0ee9bb7 26:65d5a0ca49ae
39 import java.util.List; 39 import java.util.List;
40 import java.util.Map; 40 import java.util.Map;
41 import java.util.Set; 41 import java.util.Set;
42 42
43 public abstract class ModuleDao { 43 public abstract class ModuleDao {
44
45 /**
46 * Maps database columns to POJO fields.
47 * @param result the database result set
48 * @param mod the POJO
49 * @throws SQLException
50 */
51 protected void mapColumns(ResultSet result, Module mod) throws SQLException {
52 mod.setModID(result.getInt("modid"));
53 mod.setClassname(result.getString("classname"));
54 mod.setVisible(result.getBoolean("visible"));
55 }
56
44 57
45 /** 58 /**
46 * Must return a prepared statement for a single object query with the specified properties. 59 * Must return a prepared statement for a single object query with the specified properties.
47 * 60 *
48 * <ul> 61 * <ul>
134 try ( 147 try (
135 Statement stmt = conn.createStatement(); 148 Statement stmt = conn.createStatement();
136 ResultSet result = stmt.executeQuery("SELECT * FROM lpitcore_module")) { 149 ResultSet result = stmt.executeQuery("SELECT * FROM lpitcore_module")) {
137 while (result.next()) { 150 while (result.next()) {
138 final Module mod = new Module(); 151 final Module mod = new Module();
139 mod.setModID(result.getInt("modid")); 152 mapColumns(result, mod);
140 mod.setClassname(result.getString("classname"));
141 mod.setVisible(result.getBoolean("visible"));
142 list.add(mod); 153 list.add(mod);
143 } 154 }
144 } 155 }
145 return list; 156 return list;
146 } 157 }

mercurial