Spring Security is a framework that provides authentication, authorization, and protection against common attacks.
(spring document) : https://docs.spring.io/spring-security/site/docs/current/reference/html5/
인증과 인가 및 보호를 제공하는 프레임워크다.
The OAuth 2.0 authorization framework enables a third-party
application to obtain limited access to an HTTP service
(OAuth docs) : https://datatracker.ietf.org/doc/html/rfc6749
타사 서비스에 대한 제한된 접근을 얻기 위한 애플리케이션이다.
👆 인증 절차 간소화 : 기능 단순화 및 규모 확장성을 지원을 위해 디지털 서명 기반의 암호화 대신 HTTPS의 암호화에 맡김
👆 용어 변경
🤟 다양한 인증 방식 제공 : Authorization code Grant 방식 뿐만 아니라 Device code Grant, Implicit Grant 등의 많은 인증 방식 제공
It makes it easier to build Spring-powered applications that use data access technologies.
(Spring docs) : https://spring.io/projects/spring-data-jpa
데이터 접근을 필요로 하는 Spring 기반 애플리케이션을 더 쉽게 구축할 수 있다.
🔎 JPA(Java Persistence API) : 자바 진영의 ORM 기술 표준 인터페이스
🔎 ORM(Object Relational Mapping) : 객체(클래스) 와 관계형 데이터 베이스(관계) 와의 설정
이때까지
🌖 관계형 DB에는 객체를 가질 수 없다.
🌗 객체지향적인 표현이 되지 않는다.
🌑 => 패러다임의 불일치
물리적으로는 SQL과 JDBC API를 데이터 접근 계층에 숨겼을 지라도,
논리적으로는 Entity와 상당한 의존관계를 가지고 있다.
이를 해결하고자 ORM( JPA(인터페이스), Hibernate(구현체) )가 등장
🔎 비영속(new/transient): 영속성 컨텍스트와 전혀 관계가 없는 상태
🔎 영속(managed): 영속성 컨텍스트에 저장된 상태
🔎 준영속(detached): 영속성 컨텍스트에 저장되었다가 분리된 상태
🔎 삭제(removed): 삭제된 상태
👆 Lazy Loading(지연 로딩) : proxy 객체를 사용하여 필요한 내용만 가져옴(불필요한 데이터까지 가져올 필요가 없음)
✌ Dirty Checking(변경 감지) : snapshot을 이용하여 변경된 부분을 알아서 찾아냄(영속 상태의 엔티티만 적용)
🤟 Caching(1차 캐시) : 영속성 컨텍스트 내부 캐시에 엔티티를 저장함(캐시에 저장된 내용을 요청시 DB를 접근하지 않고 캐시에서 줌)
🖖 동일성 보장 : 영속성 컨텍스트는 엔티티의 동일성을 보장한다.
👉 spring framework에서 JPA를 편리하게 사용할 수 있도록 지원
🎯 JPA 연관관계 매핑에 대한 이해 부족
public class User {
//~생략//
@OneToMany(mappedBy = "user", fetch = FetchType.EAGER,cascade = CascadeType.REMOVE)
@JsonIgnoreProperties({"user"})
@OrderBy("id desc")
private List<Review> review;
}
class Room {
//~생략//
@OneToMany(mappedBy = "room",fetch = FetchType.EAGER,cascade = CascadeType.REMOVE)
@JsonIgnoreProperties({"room"})// 무한 참조 방지
@OrderBy("id desc")
private List<Review> review;
@OneToMany(mappedBy = "reservationRoom",fetch = FetchType.LAZY,cascade = CascadeType.REMOVE)
@JsonIgnoreProperties({"reservationRoom"})
@OrderBy("id desc")
private List<Reservation> reservations;
}
class Review {
//~생략//
@ManyToOne
@JoinColumn(name = "roomId")
private Room room;
@ManyToOne
@JoinColumn(name = "userId")
private User user;
}
public class Reservation {
//~생략//
@ManyToOne
@JoinColumn(name = "roomId")
private Room reservationRoom;
}
📃 연관관계 매핑하는 과정에서의 연관관계 주인, mappedby와 같이 이해가 부족했었음.
🎯 쿼리에 대한 실력 부족(JPQL, QueryDSL이 아닌 순수 쿼리)
public List<Room> findRoomByReservation(Reservation reservation) throws ParseException {
//~생략//
if (RstartDate.after(endDate) && reservation.getRoomType().equals(room.getRoomType()) &&
reservation.getCountPerson() <= room.getMaxPerson()){
findRoom.add(room);
}
}
//~생략//
}
📃 쿼리를 짜는 실력이 부족하여 Service 부분에서 if문으로 처리함.