3Layer Architecture는 서버에서 처리과정을 Controller, Service, Repository 3가지로 나눈 것
Controller : 클라이언트의 요청을 서비스에 전달한다.
Service : 실제 비지니스 로직을 처리하는 영역
Repository : DB와 소통하며 CRUD기능을 담당한다.
JPA Repository는 아래 코드와 같이 상속 받으면 Query문을 함수 이름으로 간편하게 사용할 수 있도록 해준다.
@Transactional
@Repository
public interface PostRepository extends JpaRepository<Post, Long> {
List<Post> findAllByOrderByCreateAtDesc();
}