2021-05-27-TIL
2021-05-27-TIL
쿼리별 메서드 오버로딩? vs 동적 쿼리 생성
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
public List<Room> findByFilter(String location) {
return jdbcTemplate.query("SELECT * FROM room WHERE location = ?", roomRowMapper(), location);
}
public List<Room> findByFilter(String location, String checkIn, String checkOut) {
return jdbcTemplate.query("SELECT * FROM room WHERE location = ? AND id NOT IN (SELECT room_id FROM reserve WHERE check_in < ? AND check_out > ?)", roomRowMapper(), location, checkOut, checkIn);
}
public List<Room> findByFilter(String location, String checkIn, String checkOut, Integer min, Integer max) {
return jdbcTemplate.query("SELECT * FROM room WHERE location = ? AND id NOT IN (SELECT room_id FROM reserve WHERE check_in < ? AND check_out > ?) AND (charge BETWEEN ? AND ?)", roomRowMapper(), location, checkIn, checkOut, min, max);
}
public List<Room> findByFilter(String location, String checkIn, String checkOut, Integer min, Integer max, Integer guests) {
return jdbcTemplate.query("SELECT * FROM room WHERE location = ? AND id NOT IN (SELECT room_id FROM reserve WHERE check_in < ? AND check_out > ?) AND (charge BETWEEN ? AND ?) AND guests >= ?", roomRowMapper(), location, checkIn, checkOut, min, max, guests);
}
GRASP 패턴
- https://nesoy.github.io/articles/2019-05/GRASP-Pattern
RID
- https://blog.sqlauthority.com/2020/01/25/sql-server-heaps-scans-and-rid-lookup/#:~:text=RID%20Lookup%3A%20A%20RID%20Lookup,data%20in%20the%20heap%20table.
Non-Repeatable Read vs Phantom Read
- https://stackoverflow.com/questions/11043712/what-is-the-difference-between-non-repeatable-read-and-phantom-read
- https://postgresql.kr/blog/pg_phantom_read.html
This post is licensed under CC BY 4.0 by the author.