Skip to content

Commit

Permalink
Merge pull request spring-projects#37166 from quaff
Browse files Browse the repository at this point in the history
* pr/37166:
  Continue polishing

Closes spring-projectsgh-37166
  • Loading branch information
mhalbritter committed Sep 6, 2023
2 parents 2660909 + 4c39cc2 commit 65c739e
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,26 @@
* @author Stephane Nicoll
*/
@Repository
public class ExampleRepository {
class ExampleRepository {

private static final ExampleEntityRowMapper ROW_MAPPER = new ExampleEntityRowMapper();

private final JdbcTemplate jdbcTemplate;

public ExampleRepository(JdbcTemplate jdbcTemplate) {
ExampleRepository(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}

@Transactional
public void save(ExampleEntity entity) {
void save(ExampleEntity entity) {
this.jdbcTemplate.update("insert into example (id, name) values (?, ?)", entity.getId(), entity.getName());
}

public ExampleEntity findById(int id) {
ExampleEntity findById(int id) {
return this.jdbcTemplate.queryForObject("select id, name from example where id =?", ROW_MAPPER, id);
}

public Collection<ExampleEntity> findAll() {
Collection<ExampleEntity> findAll() {
return this.jdbcTemplate.query("select id, name from example", ROW_MAPPER);
}

Expand Down

0 comments on commit 65c739e

Please sign in to comment.