Allon Mureinik has uploaded a new change for review. Change subject: core: Singleton row mapper for VdcOption ......................................................................
core: Singleton row mapper for VdcOption Added a singleton row mapper for VdcOptionDAO, as specified by http://www.ovirt.org/Backend_Coding_Standards . Change-Id: Idb2e777ba64f285d550825c65cf047c9cc91ac76 Signed-off-by: Allon Mureinik <[email protected]> --- M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdcOptionDAODbFacadeImpl.java 1 file changed, 20 insertions(+), 43 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/74/12574/1 diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdcOptionDAODbFacadeImpl.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdcOptionDAODbFacadeImpl.java index bfb4725..8c320c3 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdcOptionDAODbFacadeImpl.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdcOptionDAODbFacadeImpl.java @@ -3,9 +3,10 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.List; + +import org.ovirt.engine.core.common.businessentities.VdcOption; import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; import org.springframework.jdbc.core.simple.ParameterizedRowMapper; -import org.ovirt.engine.core.common.businessentities.VdcOption; /** * <code>VdcOptionDAODbFacadeImpl</code> provides a concrete implementation of {@link VdcOptionDAO} using code @@ -15,25 +16,27 @@ */ public class VdcOptionDAODbFacadeImpl extends BaseDAODbFacade implements VdcOptionDAO { + private static final class VdcOptionRowMapper implements ParameterizedRowMapper<VdcOption> { + public static final VdcOptionRowMapper instance = new VdcOptionRowMapper(); + + @Override + public VdcOption mapRow(ResultSet rs, int rowNum) + throws SQLException { + VdcOption entity = new VdcOption(); + entity.setoption_name(rs.getString("option_name")); + entity.setoption_value(rs.getString("option_value")); + entity.setoption_id(rs.getInt("option_id")); + entity.setversion(rs.getString("version")); + return entity; + } + } + @Override public VdcOption get(int id) { MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource() .addValue("option_id", id); - ParameterizedRowMapper<VdcOption> mapper = new ParameterizedRowMapper<VdcOption>() { - @Override - public VdcOption mapRow(ResultSet rs, int rowNum) - throws SQLException { - VdcOption entity = new VdcOption(); - entity.setoption_name(rs.getString("option_name")); - entity.setoption_value(rs.getString("option_value")); - entity.setoption_id(rs.getInt("option_id")); - entity.setversion(rs.getString("version")); - return entity; - } - }; - - return getCallsHandler().executeRead("GetVdcOptionById", mapper, parameterSource); + return getCallsHandler().executeRead("GetVdcOptionById", VdcOptionRowMapper.instance, parameterSource); } @Override @@ -41,20 +44,7 @@ MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource() .addValue("option_name", name).addValue("version", version); - ParameterizedRowMapper<VdcOption> mapper = new ParameterizedRowMapper<VdcOption>() { - @Override - public VdcOption mapRow(ResultSet rs, int rowNum) - throws SQLException { - VdcOption entity = new VdcOption(); - entity.setoption_name(rs.getString("option_name")); - entity.setoption_value(rs.getString("option_value")); - entity.setoption_id(rs.getInt("option_id")); - entity.setversion(rs.getString("version")); - return entity; - } - }; - - return getCallsHandler().executeRead("GetVdcOptionByName", mapper, parameterSource); + return getCallsHandler().executeRead("GetVdcOptionByName", VdcOptionRowMapper.instance, parameterSource); } @SuppressWarnings("unchecked") @@ -62,20 +52,7 @@ public List<VdcOption> getAll() { MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource(); - ParameterizedRowMapper<VdcOption> mapper = new ParameterizedRowMapper<VdcOption>() { - @Override - public VdcOption mapRow(ResultSet rs, int rowNum) - throws SQLException { - VdcOption entity = new VdcOption(); - entity.setoption_name(rs.getString("option_name")); - entity.setoption_value(rs.getString("option_value")); - entity.setoption_id(rs.getInt("option_id")); - entity.setversion(rs.getString("version")); - return entity; - } - }; - - return getCallsHandler().executeReadList("GetAllFromVdcOption", mapper, parameterSource); + return getCallsHandler().executeReadList("GetAllFromVdcOption", VdcOptionRowMapper.instance, parameterSource); } @Override -- To view, visit http://gerrit.ovirt.org/12574 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Idb2e777ba64f285d550825c65cf047c9cc91ac76 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Allon Mureinik <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
