spring
![[Spring boot] JPA dirty checking 시행 시점](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2Fk9UdY%2FbtrEZb8G8rE%2FAAAAAAAAAAAAAAAAAAAAAKe5PAzML1zcAq6A2u1ylVACj2tLkYetWCzA0zOsrVGB%2Fimg.png%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1753973999%26allow_ip%3D%26allow_referer%3D%26signature%3DAE%252BIrAb9ZHbq3YJuLfntBtpQQCs%253D)
[Spring boot] JPA dirty checking 시행 시점
직접 @Transactional 어노테이션이 달린 메소드를 실행해보며 언제 db에 저장되는지 확인해보자 PostApiController.java @PostMapping("api/v1/post/{id}") public PostResponseDto update(@PathVariable Long id, @RequestBody PostUpdateRequestDto requestDto){ System.out.println("transaction 시작"); PostResponseDto dto= postService.update(id, requestDto); System.out.println("transaction 종료"); return dto; } PostService.java @Transactional publi..
[Spring boot] 같은 url, 다른 parameter
스프링 부트의 컨트롤러에서 같은 url을 사용할 경우, ambiguous mapping found 오류가 발생한다. 이를 해결하기 위해서는 아래와 같이 설정하면 된다. 같은 url 이더라도 parameter가 다르다면 그 사실을 Mapping annotation에 명시해주자. @GetMapping(value = "api/v1/post", params = "title") // 같은 url 다른 param은 Mapping의 params를 이용하면 겹치는 오류가 발생하지 않는다. public List findByTitle(@RequestParam(name = "title") String title) { return postService.findByTitle(title); } @GetMapping("api/v1..

Error executing DDL 오류 해결방법
스프링부트와 aws로 혼자 구현하는 웹서비스를 진행하는 중 p.219에서 해결되는 MockMvc 설정 문제를 진행하던 중, MockMvc와 별개로 테이블이 생성되지 않는 상황이 발생했다. h2와 hibernate가 계속 업데이트 되며 발생한 일이거나 내가 뭔가 잘못 설정하여 일어난 일이겠지만 일단 테이블이 생성되지 않는다는 점을 참고하여 jdbc-url을 테스트용 application.yml 파일에 추가하였고 그 후 이 문제를 해결한 상황이다. 밑은 수정 후의 yml 파일 내용이다. spring: jpa: show_sql: true properties: hibernate: dialect: org.hibernate.dialect.MySQL57Dialect datasource: hikari: jdbc-url..
JPA Auditing 이란?
Audit : 감시, 감사하다. Spring Data provides sophisticated support to transparently keep track of who created or changed an entity and when the change happened. To benefit from that functionality, you have to equip your entity classes with auditing metadata that can be defined either using annotations or by implementing an interface. Spring Data JPA ships with an entity listener that can be used to tr..