Created
October 12, 2014 21:16
-
-
Save gabanox/8d1a203c426addc5a137 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public List<Contact> findAll() { | |
String sql = "select id, first_name, last_name, birth_date from contact"; | |
return jdbcTemplate.query(sql, new ContactMapper()); | |
} | |
public List<Contact> findAllWithDetail() { | |
String sql = "select c.id, c.first_name, c.last_name, c.birth_date" + | |
", t.id as contact_tel_id, t.tel_type, t.tel_number from contact c " + | |
"left join contact_tel_detail t on c.id = t.contact_id"; | |
return jdbcTemplate.query(sql, new ContactWithDetailExtractor()); | |
} | |
public String findFirstNameById(Long id) { | |
String firstName = jdbcTemplate.queryForObject( | |
"select first_name from contact where id = ?", | |
new Object[]{id}, String.class); | |
return firstName; | |
} | |
public String findLastNameById(Long id) { | |
String sql = "select last_name from contact where id = :contactId"; | |
SqlParameterSource namedParameters = new MapSqlParameterSource("contactId", id); | |
//Map<String, Object> namedParameters = new HashMap<String, Object>(); | |
//namedParameters.put("contactId", id); | |
return namedParameterJdbcTemplate.queryForObject(sql, namedParameters, String.class); | |
} | |
public List<Contact> findByFirstName(String firstName) { | |
return null; | |
} | |
public void insert(Contact contact) { | |
} | |
public void update(Contact contact) { | |
} | |
public void delete(Long contactId) { | |
} | |
public void insertWithDetail(Contact contact) { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment