package br.com.senac.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import javax.sql.DataSource;

import br.com.senac.model.Email;

public class EmailDAO extends DAOSpringJdbc<Email>{

	public EmailDAO(DataSource dataSource) {
		super(dataSource);
	}

	@Override
	protected Email buildEntity(ResultSet rs) {
		Email e = new Email();
		try {
			e.setId(rs.getInt("id"));
			e.setEmail(rs.getString("email"));
			e.setIdCliente(rs.getInt("idCliente"));
		} catch (SQLException ex) {
			ex.printStackTrace();
			System.exit(1);
		}
		return e;
	}
	
	@Override
	protected String buildQueryFindAll() {
		return "select id, email from Email";
	}
	@Override
	protected String buildQueryFindById() {
		return "select id, email from Email where id = ?";
	}

}
