@Repository
DAO class에서 쓰임
데이터베이스와 연동하여 데이터를 저장하거나 조회하는 데이터 계층의 클래스
@Repository
public class UserRepository {
@Autowired
private JdbcTemplate jdbcTemplate;
public User findById(Long id) {
String sql = "SELECT * FROM user WHERE id = ?";
return jdbcTemplate.queryForObject(sql, new Object[] { id }, new UserRowMapper());
}
}
https://standout.tistory.com/477
https://standout.tistory.com/91
https://standout.tistory.com/379
https://standout.tistory.com/48
'JAVA > Spring' 카테고리의 다른 글
Annotation - @ComponentScan (0) | 2023.04.20 |
---|---|
Annotation - @Configuration (0) | 2023.04.20 |
Annotation - @Service (0) | 2023.04.19 |
Annotation - @PostMapping (0) | 2023.04.19 |
Annotation - @GetMapping (0) | 2023.04.19 |