List of usage examples for org.springframework.jdbc.core RowMapper RowMapper
RowMapper
From source file:com.sfs.whichdoctor.dao.OnlineToolDAOImpl.java
/** * Loads the requested online tool bean based on its id. * * @param referenceGUID the reference GUID * * @return the collection< online tool bean> * * @throws WhichDoctorDaoException the which doctor dao exception */// w ww . j a va2 s . c o m @SuppressWarnings("unchecked") public final OnlineToolBean loadId(final int onlineToolId) throws WhichDoctorDaoException { OnlineToolBean onlineTool = null; try { onlineTool = this.getJdbcTemplateReader().queryForObject(this.getSQL().getValue("onlineTool/loadId"), new Object[] { onlineToolId }, new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return loadOnlineTool(rs); } }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results found for this search: " + ie.getMessage()); } return onlineTool; }
From source file:com.sfs.whichdoctor.dao.ReportDAOImpl.java
/** * Used to get an Collection of ReportBeans for a specified GUID number. * * @param guid the guid// w w w. ja v a 2s. c om * @param fullResults the full results * @return the collection * @throws WhichDoctorDaoException the which doctor dao exception */ @SuppressWarnings("unchecked") public final Collection<ReportBean> load(final int guid, final boolean fullResults) throws WhichDoctorDaoException { dataLogger.info("Reports for GUID: " + guid + " requested"); final String loadReport = getSQL().getValue("report/load") + " WHERE report.Active = true AND report.ReferenceGUID = ?" + " ORDER BY reporttype.Value, report.AuthorOrder"; Collection<ReportBean> reports = new ArrayList<ReportBean>(); try { reports = this.getJdbcTemplateReader().query(loadReport, new Object[] { guid }, new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return loadReport(rs); } }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results found for this search: " + ie.getMessage()); } return reports; }
From source file:CRM.repository.ClientsDAO.java
public List<clients> getClientsByPage(int start, int total) { String sql = "SELECT * FROM clients LIMIT " + (start - 1) + "," + total; return template.query(sql, new RowMapper<clients>() { public clients mapRow(ResultSet rs, int row) throws SQLException { clients c = new clients(); c.setClient_id(rs.getInt(1)); c.setFirst_name(rs.getString(2)); c.setLast_name(rs.getString(3)); c.setAddress_1(rs.getString(4)); c.setAddress_2(rs.getString(5)); c.setAddress_3(rs.getString(6)); c.setCity(rs.getString(7));/*from w ww. j a v a 2s. com*/ c.setState(rs.getString(8)); c.setZip(rs.getString(9)); c.setPhone(rs.getString(10)); c.setFax(rs.getString(11)); c.setEmail(rs.getString(12)); c.setDate_of_hire(rs.getString(13)); c.setFile_number(rs.getString(14)); c.setStatus(rs.getString(15)); return c; } }); }
From source file:sample.contact.dao.impl.MenuDaoImpl.java
public List<Menu> findAll() { return getJdbcTemplate().query("select id, menu_name, menu_path from menus order by id", new RowMapper<Menu>() { public Menu mapRow(ResultSet rs, int rowNum) throws SQLException { return mapMenu(rs); }/*from w w w . ja v a 2 s . c o m*/ }); }
From source file:nl.surfnet.coin.shared.log.ApiCallLogServiceImpl.java
@Override public List<String> findServiceProviders() { return jdbcTemplate.query("select distinct spentity_id from api_call_log;", new RowMapper<String>() { @Override//from w ww .jav a2 s . c o m public String mapRow(ResultSet rs, int rowNum) throws SQLException { return rs.getString("spentity_id"); } }); }
From source file:com.sfs.whichdoctor.dao.WorkshopDAOImpl.java
/** * Used to get a WorkshopBean for a workshop Id. * * @param workshopId the workshop id/*from w w w .ja va 2 s .c o m*/ * @return the workshop bean * @throws WhichDoctorDaoException the which doctor dao exception */ public final WorkshopBean load(final int workshopId) throws WhichDoctorDaoException { dataLogger.info("WorkshopId: " + workshopId + " requested"); final String loadId = getSQL().getValue("workshop/load") + " WHERE workshop.WorkshopId = ?"; WorkshopBean workshop = null; try { workshop = (WorkshopBean) this.getJdbcTemplateReader().queryForObject(loadId, new Object[] { workshopId }, new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return loadWorkshop(rs, true); } }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results for this search: " + ie.getMessage()); } return workshop; }
From source file:com.ewcms.component.interaction.dao.InteractionDAO.java
@Override public Interaction getInteraction(Integer id) { String sql = "Select * From plugin_interaction Where id = ?"; List<Interaction> list = jdbcTemplate.query(sql, new Object[] { id }, new RowMapper<Interaction>() { @Override/* w w w . j av a 2 s. c o m*/ public Interaction mapRow(ResultSet rs, int rowNum) throws SQLException { return interactionRowMapper(rs); } }); return list.isEmpty() ? null : list.get(0); }
From source file:org.tibetjungle.demo.dao.ContactDaoImpl.java
public Contact getById(Long id) { List<Contact> list = getJdbcTemplate().query( "select id, contact_name, email from contacts where id = ? order by id", new RowMapper<Contact>() { public Contact mapRow(ResultSet rs, int rowNum) throws SQLException { return mapContact(rs); }//from ww w . j a v a2s . co m }, id); if (list.size() == 0) { return null; } else { return (Contact) list.get(0); } }
From source file:edu.uca.aca2016.impulse.repository.InteractionsDAO.java
/** * List<Interactions> getAPIInteractionsList method and SQL Query * @return/*from w w w . ja va 2 s .co m*/ */ public List<Interactions> getAPIInteractionsList() { return template.query("SELECT * FROM Interactions ", new RowMapper<Interactions>() { @Override public Interactions mapRow(ResultSet rs, int row) throws SQLException { Interactions i = new Interactions(); i.setInteractionId(rs.getInt(1)); i.setClientid(rs.getInt(2)); i.setOccurredOn(rs.getNString(3)); i.setContactPerson(rs.getString(4)); i.setContactType(rs.getString(5)); i.setNotes(rs.getString(6)); return i; } }); }
From source file:act.reports.dao.AuctionListInvoicesDAO.java
public AuctionListInvoices getAuctionListInvoicesDetails(SearchCriteria criteria) { logger.info("In AuctionListInvoicesDAO-getAuctionListInvoicesDetails()..."); AuctionListInvoices auctionListInvoices = new AuctionListInvoices(); //AuctionList auctionList = new AuctionList(); List<AuctionListInvoicesDetails> auctionListInvoicesDetailsList = null; try {//from w ww .j a v a 2s. c om String auctionListId = criteria.getAuctionListId(); String auctionListName = criteria.getAuctionListName(); logger.info( "auctionListId in AuctionListInvoicesDAO-getAuctionListInvoicesDetails() : " + auctionListId); logger.info("auctionListName in AuctionListInvoicesDAO-getAuctionListInvoicesDetails() : " + auctionListName); String auctionListInvoiceDetailsqQuery = "select ali.invoiceId,ali.auctionDate,i.dropOffLocation,iv.vehicle_Year,iv.vehicle_Make,iv.vehicle_Model,iv.vehicle_VIN,iv.vehicle_Country,vehicle_State,iv.vehicle_Plate_No,ir.releaseTo from AuctionList_Invoices ali LEFT OUTER JOIN Invoice i ON ali.invoiceId=i.invoiceId " + "LEFT OUTER JOIN Invoice_Vehicle iv ON ali.invoiceId=iv.invoiceId LEFT OUTER JOIN Invoice_Release ir ON ali.invoiceId=ir.invoiceId where ali.auctionListId='" + auctionListId + "' and ali.auctionListName='" + auctionListName + "' order by ali.invoiceId"; auctionListInvoicesDetailsList = jdbcTemplate.query(auctionListInvoiceDetailsqQuery, new Object[] {}, new RowMapper<AuctionListInvoicesDetails>() { public AuctionListInvoicesDetails mapRow(ResultSet rs, int rowNum) throws SQLException { AuctionListInvoicesDetails auctionListInvoicesDetails = new AuctionListInvoicesDetails(); String invoiceId = (rs.getString("invoiceId") != null) ? rs.getString("invoiceId") : ""; auctionListInvoicesDetails.setInvoiceId(invoiceId); auctionListInvoicesDetails.setAuctionDate( (rs.getString("auctionDate") != null) ? rs.getString("auctionDate") : ""); auctionListInvoicesDetails.setLotLocation( (rs.getString("dropOffLocation") != null) ? rs.getString("dropOffLocation") : ""); auctionListInvoicesDetails.setVehicleYear( (rs.getString("vehicle_Year") != null) ? rs.getString("vehicle_Year") : ""); auctionListInvoicesDetails.setVehicleMake( (rs.getString("vehicle_Make") != null) ? rs.getString("vehicle_Make") : ""); auctionListInvoicesDetails.setVehicleModel( (rs.getString("vehicle_Model") != null) ? rs.getString("vehicle_Model") : ""); auctionListInvoicesDetails.setVehicleVIN( (rs.getString("vehicle_VIN") != null) ? rs.getString("vehicle_VIN") : ""); auctionListInvoicesDetails.setLicensePlateCountry( (rs.getString("vehicle_Country") != null) ? rs.getString("vehicle_Country") : ""); auctionListInvoicesDetails.setLicensePlateState( (rs.getString("vehicle_State") != null) ? rs.getString("vehicle_State") : ""); auctionListInvoicesDetails.setLicensePlateNo( (rs.getString("vehicle_Plate_No") != null) ? rs.getString("vehicle_Plate_No") : ""); if (!invoiceId.isEmpty()) { if (getIsSalvageCall(invoiceId)) auctionListInvoicesDetails.setMarkedAsSalvage("Y"); else auctionListInvoicesDetails.setMarkedAsSalvage("N"); } int releaseTo = rs.getInt("releaseTo"); auctionListInvoicesDetails.setReleasedTo(getAccountName(releaseTo)); //releaseTo return auctionListInvoicesDetails; } }); auctionListInvoices.setAuctionListId(auctionListId); auctionListInvoices.setAuctionListName(auctionListName); if (auctionListInvoicesDetailsList.size() > 0) auctionListInvoices.setAuctionDate(auctionListInvoicesDetailsList.get(0).getAuctionDate()); else auctionListInvoices.setAuctionDate(" "); auctionListInvoices.setAuctionListInvoicesDetailsList(auctionListInvoicesDetailsList); auctionListInvoices.setTotalVehicles(Integer.toString(auctionListInvoicesDetailsList.size())); } catch (Exception e) { logger.error(e); e.printStackTrace(); } return auctionListInvoices; }