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

changeset 26
65d5a0ca49ae
parent 24
8137ec335416
child 27
1f2a96efa69f
--- a/src/java/de/uapcore/lightpit/entities/ModuleDao.java	Sun Apr 08 14:41:10 2018 +0200
+++ b/src/java/de/uapcore/lightpit/entities/ModuleDao.java	Sun Apr 08 15:34:11 2018 +0200
@@ -43,6 +43,19 @@
 public abstract class ModuleDao {
     
     /**
+     * Maps database columns to POJO fields.
+     * @param result the database result set
+     * @param mod the POJO
+     * @throws SQLException 
+     */
+    protected void mapColumns(ResultSet result, Module mod) throws SQLException {
+        mod.setModID(result.getInt("modid"));
+        mod.setClassname(result.getString("classname"));
+        mod.setVisible(result.getBoolean("visible"));
+    }
+            
+    
+    /**
      * Must return a prepared statement for a single object query with the specified properties.
      * 
      * <ul>
@@ -136,9 +149,7 @@
                 ResultSet result = stmt.executeQuery("SELECT * FROM lpitcore_module")) {
             while (result.next()) {
                 final Module mod = new Module();
-                mod.setModID(result.getInt("modid"));
-                mod.setClassname(result.getString("classname"));
-                mod.setVisible(result.getBoolean("visible"));
+                mapColumns(result, mod);
                 list.add(mod);
             }
         }

mercurial