분류 전체보기

    회원 서비스 개발 //의존관계주입, @Transactional(readOnly)

    @Transactional(readOnly=true) 읽기전용모드 => 속도up 문제:쓰기가안됨 해결:쓰기해야되는 메소드위에 @Transactional(readOnly=false) package jpabook.jpashop.service; import jpabook.jpashop.domain.Member; import jpabook.jpashop.repository.MemberRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional;..

    회원 리포지토리 개발

    @Repository @PersistentContext em사용법 익히기 package jpabook.jpashop.repository; import jpabook.jpashop.domain.Member; import org.springframework.stereotype.Repository; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import java.util.List; @Repository //component scan => 자동으로 스프링빈으로 등록해줘 public class MemberRepository { @PersistenceContext //EntityManager만들어서 주입해줘..

    엔티티 설계시 주의점 // Setter제거

    엔티티 설계시 주의점 // Setter제거

    * Setter제거 문제 : Setter 무분별허용 => 오브젝트가 어디서 수정됬는지 모름 => 유지보수어렵 해결? : ??? 뒷강의(어플개발강의)에서 Setter없이 개발하는것을 보여주겠다. *LAZY(지연로딩) ※ 절대 Eager을 사용하면 안된다. 문제 : @XToOne 은 기본값이 즉시로딩(Eager) => 연관된애들 다땡겨옴, N(결과쿼리)+1(Order 쿼리) 문제. 해결 : @XToOne(fetch=FetchType.LAZY) 1. 패키지에서 C Shift F : OneToOne, ManyToOne 모두 찾기 2 . fetch 변경 @OneToOne(fetch = LAZY,mappedBy = "delivery") private Order order; *컬렉션 초기화 문제 문제 : 메소드초기화..

    엔티티 클래스 개발1 // JPA 어노테이션

    테이블, 기본키, 기본키자동생성 @Entity @Id @GeneraedValue @Entity //Member 테이블 만들어줘. public class Member { @Id //Long id를 키로 해줘. @GeneratedValue //기본키 자동으로 생성해줘(1씩증가) private Long id; private String name; private Address address; } @Embeddable package jpabook.jpashop.domain; import lombok.Getter; import javax.persistence.Embeddable; @Embeddable //내장가능 @Getter public class Address { private String city; priva..

    JPA 실전편 환경설정 // 문제-해결 중심으로 복습

    package jpabook.jpashop; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; @Controller public class HelloController { @GetMapping("hello") //hello라는 url이오면, 호출해라 public String hello(Model model) { //hello.html안의 -- data에 hello!!로 렌더링해라. model.addAttribute("data","hello!!"); return "hello"; //resources..

    백준 12869 //visit[체력][체력][체력]=최단거리(공격횟수) /visit idx를 체력으로 사용하라.

    12869번: 뮤탈리스크 (acmicpc.net) 12869번: 뮤탈리스크 1, 3, 2 순서대로 공격을 하면, 남은 체력은 (12-9, 10-1, 4-3) = (3, 9, 1)이다. 2, 1, 3 순서대로 공격을 하면, 남은 체력은 (0, 0, 0)이다. www.acmicpc.net /* * bfs algorithm * 1.초기화 * 2.종료조건 * 3.next * 4.next 방문체크 * 5.visit[next] 갱신 */ *핵심로직 1. visit[체력][체력][체력] = 최단거리(공격횟수) 1.1 idx에 각각 체력저장. 2.v[0][0][0] 에 방문했다? -> bfs이므로 -> 최초 체력 0,0,0으로 만든애가 최단거리임. -> 출력. 끝. #include using namespace std;..

    백준 16234 인구이동 // ny,nx만처리하는 bfs / main에서 v[y][x]처리 / vector &v로 함수내 전역변수 사용

    16234번: 인구 이동 (acmicpc.net) 16234번: 인구 이동 N×N크기의 땅이 있고, 땅은 1×1개의 칸으로 나누어져 있다. 각각의 땅에는 나라가 하나씩 존재하며, r행 c열에 있는 나라에는 A[r][c]명이 살고 있다. 인접한 나라 사이에는 국경선이 존재한다. 모 www.acmicpc.net * dfs 조건처리는 contine만으로 가능, 빡구현필요X if (abs(a[y][x] - a[ny][nx]) r) continue; * for(v) 조건문실행되면 연결할게 있었다는 뜻 -> ret++, else break 조건문안에 flag=1 => 연결할게잇는지없는지 검사 !flag 이면, 종료. for (pair p : v) { a[..

    백준 4179 // 갈수있는지조사는 bfs visit 비교

    4179번: 불! (acmicpc.net) 4179번: 불! 입력의 첫째 줄에는 공백으로 구분된 두 정수 R과 C가 주어진다. 단, 1 ≤ R, C ≤ 1000 이다. R은 미로 행의 개수, C는 열의 개수이다. 다음 입력으로 R줄동안 각각의 미로 행이 주어진다. 각각의 문자 www.acmicpc.net *팁 bfs는 main안에서 짜는게 낫다. ret는 전역변수로? * 아이디어 1. 불bfs => 불 도착시간들 모두 저장 2. 사람bfs : 종료조건 -> 그때v값이 답임. ---------------------------------- 불보다 visit이 작다 -> 더빨리도착가능 -> 이동가능. == visit(불) >= 사람 -> continue; *예외처리 불이없는경우? visit(불) : 0 0 0..