return simpleJdbcTemplate.query("select ticket.number as ticket_number, lottery.name as lottery_name, customer.name as customer_name " +
"from ticket inner join customer on ticket.customer_id = customer.id inner join lottery on ticket.lottery_id = lottery.id where customer.id = ?",
new ParameterizedRowMapper<CustomerTicketsQueryResult>() {
public CustomerTicketsQueryResult mapRow(ResultSet rs, int rowNum) throws SQLException {
return new CustomerTicketsQueryResult(
rs.getString("ticket_number"),
rs.getString("lottery_name"),
rs.getString("customer_name"));
}
}, customerId);