사용법
1.oneToMany든 manyToOne이든 fetch = FetchType.LAZY를 붙혀준다
2.jpa could not initialize proxy - no session 오류발생시 참고
https://cordingmonster.tistory.com/235
jpa lazy사용시 jpa could not initialize proxy - no session 에러
두가지 방법이 있다 1.해당 함수 위에 @Transactional추가 -https://jforj.tistory.com/98 [JPA] could not initialize proxy - no Session 에러 안녕하세요. J4J입니다. JPA를 사용하다가 연관관계 매핑을 위해 @..
cordingmonster.tistory.com
테스트
1.a테이블 값만가져올때
2.a테이블 값 가져온뒤 join값을 사용할때
1번테스트
쿼리만 봐서는 응 뭐가 다른거지 할 수있지만
2번테스트
System.out.println("b테이블값 조인하기: "+aTables.get(0).getBTables().get(0).getBId());
코드가 실행될때 즉 join값을 요구할때
조회해 오는걸 알 수 있다
진짜 미쳤다 미쳤어 ㅋㅋㅋ
'Springboot > Jpa' 카테고리의 다른 글
JPA 다중 기본키(복합키) 그리고 왜래키 기본키 같이 쓰기 (0) | 2022.05.15 |
---|---|
vscode querydsl Qclass classNotFound 에러 (0) | 2022.04.04 |
@oneToMany foreign key constraint fails 해결하기 (0) | 2022.04.04 |
jpa lazy사용시 jpa could not initialize proxy - no session 에러 (0) | 2022.04.04 |
vscode에서 Jpa와 query dsl Qclass만들기 (0) | 2022.04.03 |