Java tutorial
/******************************************************************************* * Copyright (c) 2009 David Harrison. * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Public License v3.0 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/gpl-3.0.html * * Contributors: * David Harrison - initial API and implementation ******************************************************************************/ package com.sfs.dao; import com.sfs.beans.ListManagerBean; import com.sfs.beans.ListTypeBean; import java.util.Collection; import java.sql.ResultSet; import java.sql.SQLException; import org.apache.log4j.Logger; import org.springframework.dao.IncorrectResultSizeDataAccessException; import org.springframework.jdbc.core.RowMapper; /** * The Class ListManagerDAOImpl. * * @author David Harrison 26th December 2004 - extensively modified 3rd June 2008 */ public class ListManagerDAOImpl extends BaseDAOImpl implements ListManagerDAO { /** The data logger. */ private static Logger dataLogger = Logger.getLogger(ListManagerDAOImpl.class); /** * Load the list manager bean. * * @return the list manager bean * * @throws SFSDaoException the SFS dao exception */ @SuppressWarnings("unchecked") public final ListManagerBean load() throws SFSDaoException { ListManagerBean listManager = new ListManagerBean(); try { Collection<ListTypeBean> options = this.getJdbcTemplateReader() .query(this.getSQL().getValue("listmanager/load"), new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { ListTypeBean lt = new ListTypeBean(); lt.setObjectType(rs.getString("ObjectType")); lt.setClassName(rs.getString("ClassName")); lt.setInstanceName(rs.getString("InstanceName")); lt.setAbbreviation(rs.getString("Abbreviation")); lt.setDescription(rs.getString("Description")); lt.setValue(rs.getString("Value")); lt.setSecurity(rs.getString("Security")); lt.setLdapMapping(1, rs.getString("LdapMapping")); lt.setLdapMapping(2, rs.getString("SecondLdapMapping")); lt.setLdapMapping(3, rs.getString("ThirdLdapMapping")); lt.setListType(rs.getString("ListType")); return lt; } }); listManager.setListTypes(options); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results found for this search: " + ie.getMessage()); } return listManager; } }