일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- 브루트포스
- cors
- 정적 리소스
- EnableAutoConfiguration
- 리소스핸들러
- 백트래킹
- Application Runner
- Spring Security
- 백기선
- WebApplication Type
- 리소스 서버
- @ConfigurationProperties
- 백준
- JsonSerializer
- rest api
- Application Argument
- 알고리즘
- AuthenticationPrincipal
- HATEOAS
- JPA
- 스프링부트
- application.properties
- OAuth2
- Application Event
- 다익스트라
- 외부설정
- @Profile
- HttpMessageConverters
- webjar
- 스프링 부트
- Today
- Total
목록스프링 부트 (64)
아카이브

메서드 이름 기반의 자동 쿼리 만들기 방식은 너무 알아보기 힘들다는 단점이 있다. findByFirstNameIngoreCaseAndLastNameStartsWithIgnoreCase(String firstName, String lastName) 여러 쿼리 메서드는 대부분 두 가지 중 하나 Optional findOne(Predicate): 이런 저런 조건으로 무언가 하나를 찾는다. List|Page|.. findAll(Predicate): 이런 저런 조건으로 무언가 여러 개를 찾는다 QuerydslPredicateExecutor 인터페이스 QuerydslPredicateExecutor (Spring Data Core 2.4.3 API) Iterable findAll(com.querydsl.core.ty..

도메인 Entity 클래스 이벤트 발생시키기 스프링 프레임워크의 이벤트 관련 기능 https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#context-functionality-events Core Technologies In the preceding scenario, using @Autowired works well and provides the desired modularity, but determining exactly where the autowired bean definitions are declared is still somewhat ambiguous. For example, as a developer lo..
모든 리포지토리에 공통적으로 추가하고 싶은 기능이 있거나 덮어쓰고 싶은 기본 기능이 있다면 JpaRepository를 상속받는 인터페이스 정의 @NoRepositoryBean 기본 구현체를 상속 받는 커스텀 구현체 만들기 @EnableJpaRepositories에 설정 repositoryBaseClass 실습 : 어떤 엔티티가 PersistentContext에 들어있는지 확인하는 기능 구현 JpaRepository를 상속하는 CommonRepository 구현 @NoRepositoryBean// 중간 Repository들은 빈 등록이 안되게 하자. public interface CommonRepository extends JpaRepository { boolean contains(T entity); } ..
쿼리 메서드(쿼리 생성 및 미리 정의된 쿼리 찾기)로 해결되지 않는 경우 직접 구현 가능 스프링 데이터 리포지토리 인터페이스에 기능 추가 스프링 데이터 리포지토리 기본 기능 덮어쓰기 가능 구현 방법 커스텀 리포지토리 인터페이스 정의 인터페이스 구현 클래스 만들기 (기본 접미어는 Impl) 엔티티 리포지토리에 커스텀 리포지토리 인터페이스 추가 PostCustomRepository 인터페이스 정의 public interface PostCustomRepository { List findMyPost(); void delete(T entity);// 기본 기능 재정의하기 (사용자 정의 구현체가 spring-data-jpa 보다 우선순위가 높다) } PostCustomRepository 인터페이스 구현체 PostC..

스프링 데이터 저장소의 메서드 이름으로 쿼리 만드는 방법 이름을 분석해서 쿼리 만들기 (CREATE) public interface CommentRepository extends MyRepository{ //Comment title에 Keyword가 들어있는 모든 Comment를 찾아주는 메서드 List findByCommentContains(String Keyword); } 2. 미리 정의해 둔 쿼리 찾아 사용하기 (USE_DECLARED_QUERY) /** * 기본값은 JPQL * nativeQuery 설정하고 싶으면 nativeQuery = true 추가 */ //@Query(value = "SELECT c FROM Comment AS c") List findByCommentContains(Stri..

스프링 데이터 2.0부터 자바 8 Optional을 지원한다. Collection은 Null이 아닌, 비어있는 Collection을 리턴한다. Optional 인터페이스가 제공하는 메서드를 사용해서 검사할 수 있다. Optional 메서드를 통한 검사 isPresent() : 값의 유무 확인 orElse() : 값이 없다면, 다른 인스턴스를 리턴할 수 있다. orElseThrow() : 값이 없다면, 예외를 던진다. Optional 실습 테스트 MyRepository에 Optional findById 추가하기 @Nullable Optional findById(@Nullable Id id); 테스트 코드 @Test public void optionalTest() { Optional byId = commen..
Repository marker Interface를 이용하여 메서드를 직접 정의하여 사용하는 것 JpaRepository에서 들어오는 기능들이 싫고 직접 정의해서 사용하고 싶다면. 공통 인터페이스 정의 /** * Custom Repositry Define. * */ @NoRepositoryBean public interface MyRepository extends Repository { E save(E entity); List findAll(); long count(); } 공통 인터페이스를 extend 하고 사용할 수 있다 public interface CommentRepository extends MyRepository{ } 공통 인터페이스를 상속한 CommentRepository 테스트 @DataJ..

스프링 데이터 Common Repository: 단순 Marker용 Interface로 Repository 용도로 쓰일 것을 암시하는 것. CrudRepository: 기본적인 CRUD 기능들을 제공. PagingAndSortingRepository : Sort, Pageable findAll 메서드 제공 @NoRepositoryBean spring data가 runtime시 bean을 이 어노테이션이 기입된 bean을 등록하지 않도록 방지하는 것 PostRepository에 사용자 메서드 추가 /** * JPA의 기본적인 동작 원리와 빈 등록 * * @Repository가 없어도 Bean으로 등록해 줌 * @EnableJpaRepositories 여기서부터 시작한다 * EnableJpaRepositor..

JpaRepository 인터페이스 매직 인터페이스 @Repository가 없어도 빈으로 등록해 줌. @EnableJpaRepositories 매직의 시작은 여기서 부터 매직은 어떻게 이뤄지나? 시작은 @Import( JpaRepositoriesRegistrar.class ) 핵심은 ImportBeanDefinitionRegistrar 인터페이스 Bean을 프로그래밍을 통해 등록할 수 있게 한다. JpaRepository를 상속받은 모든 인터페이스들을 찾아서 빈으로 등록해준다. ImportBeanDefinitionRegistrar를 통한 Bean 등록 과정 간략 예시 /** * ImportBeanDefinitionRegistrar를 통한 Bean 등록 과정 간략 예시 */ public class Jume..
JPQL (HQL) Java Persistence Query Language / Hibernate Query Language 데이터베이스 테이블이 아닌, 엔티티 객체 모델 기반으로 쿼리 작성 JPA 또는 하이버네이트가 해당 쿼리를 SQL로 변환해서 실행함 https://docs.jboss.org/hibernate/orm/5.2/userguide/html_single/Hibernate_User_Guide.html#hql Hibernate ORM 5.2.18.Final User Guide Fetching, essentially, is the process of grabbing data from the database and making it available to the application. Tuning ..