일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 29 | 30 |
- 복합키
- @IdClass
- 최종 프로젝트
- spring서버
- git
- JPA
- github
- 스프링 부트 기능
- json gson 차이
- 인텔리제이
- jpa회원가입
- Filter
- 빈생성안됨
- 스프링부트오류
- Error creating bean with name
- jwt메서드
- queryDSL
- 스프링 부트 공식 문서
- uncheck Exception
- Unsatisfied dependency
- Q 클래스
- REST란
- JoinColumn
- jpa에러
- ERD 작성
- 1차캐시
- JPA주의사항
- Spring Spring boot 차이
- json
- REST API 규칙
- Today
- Total
목록내배캠 주요 학습/Spring 숙련 (28)
Everyday Dev System

N : M 관계 단방향 코드: package com.sparta.jpaadvance.entity; import jakarta.persistence.*; import lombok.Getter; import lombok.Setter; import java.util.ArrayList; import java.util.List; @Entity @Getter @Setter @Table(name = "food") public class Food { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; private String name; private double price; @ManyToMany @JoinTable(name = "order..

1대다 관계 말고는 일반적으로 외래키는 외래키의 주인이 DB에 갖고 있다. 1대다 관계에서 외래키의 주인이 외래키를 갖고 있지 않으니까 추가적인 update문이 발생한 것이다. 1대 N 관계 단방향 1대 N관계 에서는 1의 주인이 외래키의 주인이다. 외래키의 주인은 음식 Entity이지만, 실제 DB 테이블에는 외래키를 고객이 가지고 있는 형태이다. 외래키의 주인인 음식 Entity 외래키 필드이다. Food가 1의 관계이기 때문에 고객 Entity를 여러명을 표현하기 위해서 Java Collection인 List 활 @OneToMany @JoinColumn(name = "food_id") private List userList = new ArrayList(); @JoinColumn(name = "foo..

자세한 내용은 이전 글을 참조: 2023.06.21 - [내배캠 주요 학습/Spring 심화] - 단방향 , 양방향 외래키 활용 단방향 더보기 [entity] - Food.java package com.sparta.jpaadvance.entity; import jakarta.persistence.*; import lombok.Getter; import lombok.Setter; @Entity @Getter @Setter @Table(name = "food") public class Food { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; private String name; private double price; @Ma..

Validation, entity, 1:1 / 1:다 / 다:1 관계는 주특기 숙련주차 핵심 키워드인만큼 집중해서 들어주세요! - 외래키의 주인은 테이블에 실제 존재하는 FK의 위치이다. - 양방향일 때 FK의 주인이 누구인지 알려줘야 한다. -> 외래키의 주인이 아닌 쪽에서 mappedBy를 통해 주인을 지정한다. - mappedBy의 속성값은 외래키 주인인, 상대 Entity에 있는 필드명을 의미한다. - 외래키의 주인만이 외래키를 등록 및 삭제 추가 가능하다. 단방향의 경우엔 외래키의 주인만 상대 Entity 타입의 필드를 가진다. 양방향의 경우엔 외래키의 주인은 상대 Entity 타입의 필드를 가지면서, 상대 Entity는 외래키의 주인의 타입의 필드를 가지면 mappedBy를 통해 주인을 지정한..

- DB 테이블에서는 테이블 사이의 연관관계를 FK(외래키)로 맺을 수 있고, 방향 상관없이 조회가 가능하다. - Entity에서는 상대 Entity를 필드로 갖으면서 참조하여 Entity 사이의 연관 관계를 맺을 수 있습니다. - 서로 상대방의 entity를 참조하고 있다면 양방향이고, 하나만 참조하고 있다면 단방향이다. -> 상대 Entity를 참조하고 있지 않다면 상대 Entity를 조회할 수 있는 방법이 없다. - Entity에서는 DB에는 없는 방향이라는 개념이 존재한다. 예시) 1. Food Entity에는 양방향, 단방향 둘다 user_id 필드가 필요하다. ------Food------ @ManyToOne @JoinColumn(name="user_id") private User user;..

네이버 검색 API 활용 https://developers.naver.com/products/intro/plan/ 에서 애플리케이션 등록. API 사용 설명 관련된 사이트 https://developers.naver.com/docs/serviceapi/search/shopping/shopping.md#%EC%87%BC%ED%95%91 Postman에서 요청하기 URI : https://openapi.naver.com/v1/search/shop.json?query=macbook Client 서버에 코드 추가해서 요청하기 Code: 더보기 [naver] - [controller] package com.sparta.springresttemplateclient1.naver.controller; import co..

PathVariable 방식 & QueryParam 방식 더보기 PathVariable 방식 위와 같이 expand(query)를 입력하면 query라는 변수가 path에 {query}부분에 들어가서 요청을 보낸다. URI uri = UriComponentsBuilder .fromUriString("http://localhost:7071") .path("/api/server/post-call/{query}") .encode() .build() .expand(query) .toUri(); 서버 프로젝트의 controller 부분 @PostMapping("/post-call/{query}") public Item postCall(@PathVariable String query, @RequestBody Use..
Client 역할의 서버 관련 글: 2023.06.20 - [내배캠 주요 학습/Spring 심화] - RestTemplate - get방식 : Client 서버 코드 설명 더보기 [controller] - package com.sparta.springresttemplateserver.controller; import com.sparta.springresttemplateserver.dto.ItemResponseDto; import com.sparta.springresttemplateserver.dto.UserRequestDto; import com.sparta.springresttemplateserver.entity.Item; import com.sparta.springresttemplateserver.s..
https://github.com/Chaeyounglim/spring-resttemplate-server https://github.com/Chaeyounglim/spring-resttemplate-client1 @Slf4j log를 찍기 위해서는 해당 클래스 위에 해당 어노테이션을 기재해야 한다. 클라이언트 입장의 서버 프로젝트 생성 - web,lombok 선택 - 8081 서버 프로젝트 생성 - web,lombok 선택 - 7071 Client 서버 8081 Server 서버 7071 build.gradle에 의존성 추가 // json implementation 'org.json:json:20230227' client project 더보기 [controller] - ItemController.java..

이전 Validation 관련 글 2023.06.20 - [내배캠 주요 학습/Spring 심화] - 중요한 Validation, 예외처리 1. 의존성 추가 implementation 'org.springframework.boot:spring-boot-starter-validation' 2. Dto에 필드마다 Validation 어노테이션 기재 package com.sparta.springauth.dto; import jakarta.validation.constraints.Email; import jakarta.validation.constraints.NotBlank; import lombok.Getter; import lombok.Setter; @Getter @Setter public class Sign..