Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
Tags
- react quill custom
- springbatch
- springbatch chunk
- spring
- javascrpit 기초
- react Quill
- spring builder
- 텍스트가 많은 경우
- javascript 기초
- JPA Insert
- react jsx if
- react Page
- Spring DTO
- react forwardRef
- javascript 함수
- Spring JPA
- Docker Windows 설치
- SpringBatch 스키마
- editor Quill
- react
- step 테이블
- Spring Entity
- Spring Controller return
- Javascript
- react link
- react react-router-dom v6
- spring security
- JPA Update\
- Spring CORS
- 코드 중복제거
Archives
- Today
- Total
천천히 알아보는 코딩공부
[JPA/Hibernate] JPA 조인 쿼리문 사용 본문
JPA를 사용하면서 복잡한 쿼리문은 어떻게 사용할까 라는 의문이 든다.
JPQL를 많이 사용하게되면 처음부터 JPA를 사용하지 않고 Mybatis를 사용하지 왜 JPA를 사용할까?
실무에서는 이렇게 사용한다고 합니다
https://www.inflearn.com/questions/38771
Querydsl과 jpql을 선택하는 차이가 궁금합니다. - 인프런 | 질문 & 답변
드디어 querydsl을 배우고있네요! 제가 이해하고 있기로는, jpa에서 단순히 PK값으로 find()만 하는것이 아니기 때문에 여러가지 조건으로 검색하는 쿼리를 위해 jpql이 존재하는 것이고, jpql로 해결하
www.inflearn.com
Entity
@Entity
public class Company {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
@OneToMany(mappedBy = "company", fetch = FetchType.LAZY, cascade = CascadeType.PERSIST)
@JoinColumn(name = "company_id")
private List<Product> products = new ArrayList<>();
@OneToOne(mappedBy = "company", fetch = FetchType.LAZY)
private Employee employee;
}
@Entity
public class Employee {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "company_id")
private Company company;
}
@Entity
public class Product {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
}
Repository
@Repository
public interface EmployeeRepository extends JpaRepository<Employee, Long> {
List<Employee> findByCompany_Products_Name(String productsName);
}
결과 :

'Java > SpringBoot' 카테고리의 다른 글
[spring] DTO, Entity 차이 및 전달 로직 (0) | 2022.12.01 |
---|---|
[Spring] API로 페이징 처리 Pageable (0) | 2022.11.04 |
[Spring] JPA Select Join 일대일 일대다 (0) | 2022.10.24 |
[Spring] JPA Select (0) | 2022.10.17 |
[Spring] API 호출 시 CORS 에러 (0) | 2022.10.06 |
Comments